关键词英文为keywords,
保留字(reserved word)
保留字、关键字是在语言中有特定含义,成为语法中一部分的那些字,使用者不能再将这些字作为变量名或过程名使用。
保留字和关键字的区别是:一些保留字可能并没有应用于当前的语法中,在未来可能会被语法使用。and
Python 包含的保留字可以执行如下命令进行查看:
>>> 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']
** Python 保留字一览表**
and | as |
---|---|
assert | break |
class | continue |
def | del |
elif | else |
except | finally |
for | from |
False | global |
if | import |
in | is |
lambda | nonlocal |
not | None |
or | pass |
raise | return |
try | True |
while | with |
yield |