【发布时间】:2012-12-27 20:17:22
【问题描述】:
可能重复:
Why does “[] == False” evaluate to False when “if not []” succeeds?
逻辑测试 a==True 怎么可能产生 False,但如果 a: 有效?请看下面的代码
>>> a = bin(0)
>>> if a:
print a == True, 'HOWWWW???????'
False HOWWWW???????
>>> type(a)
<type 'str'>
>>>
【问题讨论】:
-
Python 有一个简短的表达式列表,在本文档中被评估为 false:docs.python.org/2/library/stdtypes.html#truth-value-testing