判断列表为空的方法
lists=[] def listEmpty1(lists): if not lists: return "列表为空" def listEmpty2(lists): if len(lists)==0: return "列表为空" def listEmpty3(lists): if lists: return "列表不为空" else:return "列表为空" def listEmpty4(lists): try: lists[0] except Exception as e: print(e) return "列表为空" def listEmpty5(lists): if lists is not None: return "列表为空"
print(listEmpty5(lists))