This example describes Python's keyword module usage. Share to everyone for your reference. Specific as follows:
Help on Module Keyword:name keyword-keywords (from "graminit.c") FILE /usr/lib64/python2.6/ Keyword.pydescription This file is automatically generated, please don ' t muck it up! To update the symbols in this file, ' CDs ' to the top directory of the Python source tree after building the interpreter and run: python lib/keyword.pyfunctions iskeyword = __contains__ (...) X.__contains__ (y) y in x.data __all__ = [' Iskeyword ', ' kwlist '] kwlist = [' and ', ' as ', ' assert ', ' break ', ' C ' Lass ', ' Continue ', ' def ', ...
Get a list of Python keywords:
>>> keyword.kwlist[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' from ', ' global ', ' if ', ' Import ', ' on ', ' is ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' R ' Eturn ', ' Try ', ' while ', ' with ', ' yield ' to determine if the string is a python keyword
>>> Keyword.iskeyword (' and ') true>>> >>> keyword.iskeyword (' has ') False
The above is the Python keyword module Usage example analysis content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!