python模块之keyword

时间:2023-12-28 18:00:08
# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python模块之keyword import keyword
'''
>>> help(keyword)
Help on module keyword: FUNCTIONS
iskeyword = __contains__(...)
x.__contains__(y) <==> y in x. DATA
__all__ = ['iskeyword', 'kwlist']
kwlist = ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', ... ''' #判断一个字符串是不是关键词
print keyword.iskeyword('for')#True #导出所有关键词
print keyword.kwlist
'''
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif',
'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if',
'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise',
'return', 'try', 'while', 'with', 'yield']
'''