python判断列表为空

判断列表为空的方法

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))

  

posted @ 2021-09-02 13:01  呆呆蒙蒙  阅读(478)  评论(0编辑  收藏  举报