文章内容
2020/4/27 11:09:58,作 者: 黄兵
python 判断list是否为空
判断python list是否为空,有以下几种写法:
a = [] if not a: print("List is empty")
根据长度判断:
a = [] if not len(a): print("List is empty")
或则是这么写:
a = [] if len(a) == 0: print("List is empty")
两个空list对比:
a = [] if a == []: print("List is empty")
a on 回复 有用(0)
感谢您的短信接收网站,希望越做越好~
游客so9< on 2020-04-30 09:14:53
博主回复:谢谢鼓励!