• 技术文章 >常见问题 >Python常见问题

    python判断列表是否为空

    (*-*)浩(*-*)浩2019-08-29 10:13:40原创9822

    is not None 判断

    列表不为空

    list_1 = []
    if list_1 is not None:
        print('list is not none')

    列表为空

    list_1 = []
    if list_1[0] is None:
        print('list_1 is none')

    if 列表判断

    列表不为空(空列表等于 False)

    list_2 = []
    if list_2:
        print('list_2 is not none')

    length列表长度判断

    列表为空

    list_3 = []
    if len(list_3) == 0:
        print('list_3 is none')
    list_3 = []
    if len(list):
        print('list_3 is not none')
    专题推荐:python
    品易云
    上一篇:python如何获取cookie 下一篇:python判断某一元素是否整数

    相关文章推荐

    • python正则表达式使用• python3不是内部命令• python如何查看变量的类型• python如何开发网站

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网