Python 中的标识符和保留字
保留字查看方式
import keyword
print(keyword.kwlist)
#运行结果
['False', 'None', 'True', '__peg_parser__',
'and', 'as', 'assert', 'async',
'await', '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']
标识符:变量、函数、类、模块和其他对象的起的名字
命名规则:
必须由字母、数字、下划线组成
不能以数字开头
不能是保留字
严格区分大小写