[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~
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号