保留字:某些单词被赋予了特定的含义,这些单词在对任何对象起名字时都不能用
保留字查看方法:
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']
标识符:变量、函数、类、模块和其他对象起的名字就叫标识符
命名规则:
1.可以使用字母、数字、下划线—
2.不能以数字开头
3.不能使用保留字
4.严格区分大小写