判断python中数组是否为空的方法

  介绍

这篇文章主要介绍判断python中数组是否为空的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

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

1,不是没有判断

列表不为空

list_1 =, []   if  list_1  is  not 没有:   ,,,print (& # 39; list  is  not 没有# 39;)

,列表为空

list_1 =, []   if  list_1 [0], is 没有:   ,,,print (& # 39; list_1  is 没有# 39;)

2。如果列表判断(更多学习内容,请点击)

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

list_2 =, []   if  list_2:   ,,,print (& # 39; list_2  is  not 没有# 39;)

3。长度列表长度判断

列表为空

list_3 =, []   if  len (list_3),==, 0:   ,,,print (& # 39; list_3  is 没有# 39;) list_3 =, []   if  len(列表):   ,,,print (& # 39; list_3  is  not 没有# 39;)

判断python中数组是否为空的方法