python的关键字有哪些


本文摘自php中文网,作者anonymity,侵删。

在python中若想查询python中有哪些关键字。

可以先导入keyword模块

1

2

import keyword #导入关键字模块

print(keyword.kwlist) #查询所有关键字

查询结果:

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

如果将关键字作为标识符,则会出现以下报错:

1

2

3

4

5

6

and= [1,2,1,3]

print(and)

  File "E:/Selenium_Study/111.py", line 34

    and= [1,2,1,3]

      ^

SyntaxError: invalid syntax

以上就是python的关键字有哪些的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python连接sqlite的实例教程

Python变量类型 -元组的实际运用与意义

[译]the Python tutorial#input and output

Python数据结构:一个被低估的namedtuple(一)

Python中header是什么意思

Python配置与opencv的使用详解

pycharm自带Python

Python 怎么调用百度地图api

Python之反转序列详解

Python是c语言编的吗

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...