在python shell中查看保留字列表

>>> import keyword
>>> print(len(keyword.kwlist))
33
>>> print(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']
>>>
发布了223 篇原创文章 · 获赞 160 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/u014100559/article/details/102838550