python的keyword模块用法实例分析
作者:mingaixin 时间:2022-04-06 07:56:22
本文实例讲述了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的关键字列表:
>>> 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的关键字
>>> keyword.iskeyword('and')
True
>>>
>>> keyword.iskeyword('has')
False
希望本文所述对大家的Python程序设计有所帮助。
标签:python,模块
0
投稿
猜你喜欢
写给喜欢用DW编写CSS人的一些建议
2008-05-19 12:09:00
CSS经验:因为编码差异 导致IE6不能正常解析CSS文件
2010-06-06 13:55:00
不同浏览器空格的宽度
2007-08-22 08:29:00
*.HTC 文件的简单介绍
2008-11-24 17:36:00
五步让你成为GO 语言高手
2023-06-16 18:00:41
python爬虫之urllib3的使用示例
2023-01-24 07:40:03
Python使用re模块实现正则表达式操作指南
2022-03-14 18:11:11
JS中setTimeout()的用法详解
2023-06-26 20:55:17
php简单浏览目录内容的实现代码
2023-10-25 01:32:43
asp网站生成静态页面攻略
2007-11-04 15:09:00
使用cmd命令行窗口操作SqlServer的方法
2012-07-21 14:24:06
php通过exif_read_data函数获取图片的exif信息
2023-10-27 09:01:44
人工智能学习Pytorch梯度下降优化示例详解
2023-02-11 16:28:02
asp如何在网站上提供音乐下载?
2010-06-22 21:14:00
Python的动态重新封装的教程
2023-08-23 15:26:39
Ajax+PHP边学边练 之五 图片处理
2023-11-18 07:21:29
使用Python来做一个屏幕录制工具的操作代码
2023-11-02 18:57:40
javascript中类的创建和继承
2008-05-08 12:07:00
Python绘图Matplotlib之坐标轴及刻度总结
2023-10-01 15:56:39
Python 实现取矩阵的部分列,保存为一个新的矩阵方法
2023-07-17 23:22:30