关键字 和 保留字

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_45626106/article/details/102756150

关键词英文为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

猜你喜欢

转载自blog.csdn.net/qq_45626106/article/details/102756150