definition:
BOOL () function for the given parameter to a Boolean type, without parameters, return False.
bool is a subclass of int.
grammar:
The following is the syntax bool () method:
class bool([x]
parameter
x - the parameter to be converted.
return value
Return Ture or False.
Example:
The following example demonstrates the use of bool function:
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> bool()
False
>>> bool(0)
False
>>> bool(1)
True
>>> bool(2)
True
>>> issubclass(bool,int)
True
>>> bool(' ')
True
>>> bool("")
False
>>> bool(" ")
True
>>> bool('')
False
>>> bool('A')
True