>>> import keyword
>>> dir(keyword)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__spec__',
'iskeyword', 'issoftkeyword', 'kwlist', 'softkwlist']
>>> keyword.iskeyword("for")
True
>>> keyword.issoftkeyword('for')
False
>>> keyword.softkwlist
[]
>>> 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']
>>>
コメント
コメントを投稿