Python zero-values
Are there any values other than Fa开发者_运维问答lse
, None
, 0
, and 0.0
that will return False with bool(x)
(in Python 3.X)?
http://docs.python.org/py3k/library/stdtypes.html#truth-value-testing
Any empty sequence or mapping object will also evaluate to False
:
>>> bool({})
False
>>> bool([])
False
>>> bool("")
False
>>> bool(())
False
精彩评论