查看python的所有关键字

keyword模块记录了当前python版本的所有关键字。使用keyword可以方便的查看。

import keyword #导入关键字模块
print(keyword.kwlist) #查询所有关键字
print(len(keyword.kwlist)) #查询所有关键字一共多少个

python3.7.4所有的关键字:

‘False’, ‘None’, ‘True’, ‘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’

  

原文地址:https://www.cnblogs.com/chenruhai/p/12464136.html