python关键字含义及用法
python 标准库的 keyword 模块,可以输出当前版本的所有关键字。
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
True 和 False
注意首字母大写。
True:布尔类型值,表示真;
False:布尔类型值,表示假;
and、or 和 not
用于表达式运算
and:逻辑与
or:逻辑或
not:逻辑非