python如何判断python的数组是否为空

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的数组是否为空,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注我们http://www.mobiletrain.org/


推荐阅读