python的keyword模塊用法實例分析
更新時間:2015年06月30日 17:49:42 作者:mingaixin
這篇文章主要介紹了python的keyword模塊用法,實例分析了Python中keyword模塊的基本使用技巧,需要的朋友可以參考下
本文實例講述了python的keyword模塊用法。分享給大家供大家參考。具體如下:
Help on module keyword:
NAME
keyword - Keywords (from "graminit.c")
FILE
/usr/lib64/python2.6/keyword.py
DESCRIPTION
This file is automatically generated; please don't muck it up!
To update the symbols in this file, 'cd' to the top directory of
the python source tree after building the interpreter and run:
python Lib/keyword.py
FUNCTIONS
iskeyword = __contains__(...)
x.__contains__(y) <==> y in x.
DATA
__all__ = ['iskeyword', 'kwlist']
kwlist = ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', ...
得到python的關(guān)鍵字列表:
>>> 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的關(guān)鍵字
>>> keyword.iskeyword('and')
True
>>>
>>> keyword.iskeyword('has')
False
希望本文所述對大家的Python程序設(shè)計有所幫助。
您可能感興趣的文章:
- python讀取word文檔的方法
- python實現(xiàn)在windows下操作word的方法
- Python實現(xiàn)批量讀取word中表格信息的方法
- python啟動辦公軟件進程(word、excel、ppt、以及wps的et、wps、wpp)
- python批量提取word內(nèi)信息
- Python實現(xiàn)批量將word轉(zhuǎn)html并將html內(nèi)容發(fā)布至網(wǎng)站的方法
- python實現(xiàn)登陸知乎獲得個人收藏并保存為word文件
- 利用python程序生成word和PDF文檔的方法
- Python操作Word批量生成文章的方法
- python實現(xiàn)word 2007文檔轉(zhuǎn)換為pdf文件
相關(guān)文章
python os.path.isfile()因參數(shù)問題判斷錯誤的解決
今天小編就為大家分享一篇python os.path.isfile()因參數(shù)問題判斷錯誤的解決,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11
使用Python和PySpark進行數(shù)據(jù)分析的實戰(zhàn)教程
數(shù)據(jù)分析是當今信息時代中至關(guān)重要的技能之一,Python和PySpark作為強大的工具,提供了豐富的庫和功能,使得數(shù)據(jù)分析變得更加高效和靈活,在這篇文章中,我們將深入探討如何使用Python和PySpark進行數(shù)據(jù)分析,需要的朋友可以參考下2024-01-01

