# class Test(): # pass # def __len__(self): # return 8 # def __bool__(self): # return False # test=Test() # print(bool(None)) # print(bool([])) # print(bool(test)) # False # False # True # class Test(): # pass # def __len__(self): # return 0 # # test=Test() # print(bool(None)) # print(bool([])) # print(bool(test)) # False # False # False class Test(): def __len__(self): return True def __bool__(self): return False test=Test() # print(bool(None)) # # print(bool([])) # # print(bool(test)) print(bool(Test())) print(len(Test())) True 1 # None 空 不存在 a='' b=False c=[] print(a==None) print(b==None) print(c==None) print(a is None) print(type(None)) # False # False # False # False # <class 'NoneType'>
python
最新推荐文章于 2020-10-30 22:47:27 发布