想必在座的用户都在使用Python软件,但是你们晓得Python中怎么查看关键字吗?以下文章就为各位带来了Python中查看关键字的方法,让我们一起来下文看看吧。
Python中怎么查看关键字?Python中查看关键字的方法
新建一个 查看Python中的关键字.py 文件,如图所示:

设置脚本文件的编码:# coding=gbk,如图所示:

导入 keyword 模块,代码:import keyword

输入代码:keyword.kwlist,获取python中所有的关键字,如图所示:

输入代码:print(keyword.kwlist),如图所示:

运行脚本文件,可以看到所有关键字都输出,如图所示:

以上就是小编带来的Python中查看关键字的方法,更多相关资讯教程,请关注华军下载。