后浪云Python教程:python判断列表是否为空
is not None 判断
列表不为空
list_1 = [] if list_1 is not None: print('list is not none')
列表为空
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.idc.net/help/178314/
文章版权归作者所有,未经允许请勿转载。
THE END