变量命名规则
- 可以有数字、字母、下划线组成
- 数字不能开头
- 不能使用内置关键字
- 严格区分大小写
使用命令查看关键字,代码如下:
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']