在 Python
交互模式下,输入以下代码,可以查看 Python
语言的保留字,即关键字,以下是 Python 3.9.5
的保留字:
>>> import keyword >>> keyword.kwlist ['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', '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']点击复制复制失败已复制
::: danger 警告 任何标识符不得与保留字相同,以免造成使用上的混淆。 :::
保留字列表: False
、 None
、 True
、 __peg_parser__
、 and
、 as
、 assert
、 async
、 await
、 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