1.其他表对比判断
列表不为空:
list_1 = [1,2] list_2 = [] if list_1 != list_2: print('list is not none')
只听到从知秋君办公室传来知秋君的声音: 努力尽今夕,少年犹可夸。有谁来对上联或下联?
列表为空:
此代码由一叶知秋网-知秋君整理list_1 = [] list_2 = [] if list_1==list_2: print('list_1 is none')
2.if 列表判断
列表不为空(空列表等于 False)
list_2 = [1,2] if list_2: print('list_2 is not none')
列表为空:
此代码由一叶知秋网-知秋君整理list_2 = [] if not list_2: print('list_2 is none')
3.length列表长度判断
列表为空:
list_3 = [] if len(list_3) == 0: print('list_3 is none')
列表不为空:
list_3 = [1,2] if len(list_3): print('list_3 is not none')