一、显示关键字
1.引入keyword
import keyword
print("关键字的个数为:",keyword.kwlist.__len__())
print(keyword.kwlist)
结果:
关键字的个数为: 35
['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']
2.使用help
help("keywords")
结果:
Here is a list of the Python keywords. Enter any keyword to get more help.
False class from or
None continue global pass
True def if raise
and del import return
as elif in try
assert else is while
async except lambda with
await finally nonlocal yield
break for not
二、关键字的用法
https://www.cnblogs.com/cheng10/p/9634437.html