python判断列表是否为空

2025-12-02 0 31,761

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')

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:以上部本文内容由互联网用户自发贡献,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。投诉邮箱:3758217903@qq.com

ZhiUp资源网 常见问题 python判断列表是否为空 https://www.zhiup.top/8929.html

相关