[Python]序列为空的判定

1 ListA=[]
2 ListB=[1]
3 if not ListA:
4     print("List A Empty~")
5 if ListB:
6     print("List B NOT Empty~")

最后的回显为:

1 (PythonVirtualEnv_3100) PS D:\PythonVirtualEnv> & d:/PythonVirtualEnv/PythonVirtualEnv_3100/Scripts/python.exe d:/PythonVirtualEnv/PythonVirtualEnv_391/tmp.py
2 List A Empty~
3 List B NOT Empty~

 

posted @ 2021-11-05 15:57  MoKin_Li  阅读(103)  评论(0编辑  收藏  举报