English documents:
class bool ([x])
Return a Boolean value, i.e. one ofTrueOrFalse.xis converted using the standard Truth testing procedure. Ifxis False or omitted, this returnsFalse; Otherwise it returnsTrue. TheboolClass is a subclass ofint(see Numeric Types-int, float, complex). It cannot be subclassed further. Its only instances isFalseandTrue(see Boolean Values).
Description
1. A Boolean value that returns a value of TRUE or False
2. Returns False if the parameter is default
>>> bool () #未传入参数False
3. Parameter conversions use standard logic test expressions
3.1 When you pass in a Boolean type, return by the original value
>>> bool (True) true>>> bool (false) False
3.2 An empty string returns False if the string is passed in, otherwise true
>>> bool (') false>>> bool (' 0 ') True
3.3 When the value is passed in, 0 returns false, otherwise true
>>> bool (0) false>>> bool (1) true>>> bool ( -1.0) True
3.4 When passing in tuples, lists, dictionaries, and other objects, the number of elements is null returns FALSE, otherwise true
>>> bool (()) #空元组False >>> bool ((0,)) #非空元组True >>> bool ([]) #空列表False >>> bool ([0]) #非空列表True >>> bool ({}) #空字典False >>> bool ({' K ': ' V '}) #非空字典True