介绍
这篇文章运用简单易懂的例子给大家介绍python如何判断列表是否为空,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
<强>不是没有判断强>
<>强列表不为空强>
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;)
<强>如果列表判断强>
列表不为空(空列表等于假)
list_2 =, [] if list_2: ,,,print (& # 39; list_2  is not 没有# 39;)
<强>长度列表长度判断强>
列表为空
list_3 =, [] if len (list_3),==, 0: ,,,print (& # 39; list_3  is 没有# 39;)
list_3 =, [] if len(列表): ,,,print (& # 39; list_3  is not 没有# 39;)