首页 / 知识

python判断列表值是否为空

2023-11-12 13:17:00

python中判断一个列表是否为空,可以使用以下方法

1、isnotNone判断

列表不为空

list_1=[]

iflist_1isnotNone:

print('listisnotnone')

列表为空

list_1=[]

iflist_1[0]isNone:

print('list_1isnone')

2.if列表判断

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

list_2=[]

iflist_2:

print('list_2isnotnone')

3.length列表长度判断

列表为空

list_3=[]

iflen(list_3)==0:

print('list_3isnone')

list_3=[]

iflen(list):

print('list_3isnotnone')

以上内容为大家介绍了python培训之判断列表值是否为空,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注我们

培训列表长度以上以下

最新内容

相关内容

热门文章

推荐文章

标签云

猜你喜欢