Home > Backend Development > Python Tutorial > What are the keywords of python

What are the keywords of python

anonymity
Release: 2019-06-11 11:20:51
Original
9298 people have browsed it

In python, if you want to query what keywords are in python.

What are the keywords of python

You can import the keyword module first

import keyword #导入关键字模块
print(keyword.kwlist) #查询所有关键字
Copy after login

Query results:

['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']

If you use keywords as identifiers, the following error will appear:

and= [1,2,1,3]
print(and)
  File "E:/Selenium_Study/111.py", line 34
    and= [1,2,1,3]
      ^
SyntaxError: invalid syntax
Copy after login

The above is the detailed content of What are the keywords of python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template