is not None 判断
列表不为空
<a href="https://www.gaodaima.com/tag/list" title="查看更多关于list的文章" target="_blank">list</a>_1 = [] if list_1 is not None: print('list is not <a href="https://www.gaodaima.com/tag/none" title="查看更多关于none的文章" target="_blank">none</a>')
www#gaodaima.com来源gaodai$ma#com搞$$代**码网搞代码
列表为空
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')
来源:搞代码网:原文地址:https://www.gaodaima.com