在以下情况下:
test = False test = "" test = 0test = 0.0 test = []test = () test = {} test = set()
该
if测试将有所不同:
if test: #Falseif test is not None: #True
之所以如此,是因为
is测试身份,含义
test is not None
id(test) == id(None) #False
因此
(test is not None) is (id(test) != id(None)) #True
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)