python模块之keyword
# -*- 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'] '''
无语言基础,自学python所做的各种笔记,欢迎大牛指点.