The Python boolean type

Python values ​​of all data types comes Boolean value. So much data types only need to remember only 0, None, an empty, False Boolean value is False, the rest to True.

print(bool(0))
print(bool(None))
print(bool(''))
print(bool([]))
print(bool({}))
print(bool(False))
False
False
False
False
False False

0, none, null, boolean false is false, the rest are true!

Guess you like

Origin www.cnblogs.com/ludundun/p/11260448.html