In python, if you want to query what keywords are in python.
You can import the keyword module first
import keyword #导入关键字模块 print(keyword.kwlist) #查询所有关键字
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
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!