标识符关键字
标识符&关键字
标识符
- 定义:标识符就是程序员定义的变量、函数的名称
- 明明规则:
- 见名知其意
- 可以有字母、数字、下划线组成
- 不能以数字开头
- 不能与关键字重名
关键字
- 关键字就是在python内部已经使用的标识符
- 关键字具有特殊的额功能与含义
- 开发者不允许定义与关键字同名的标识符
- 可以通过以下代码查看关键字
import keyword
print(keyword.kwlist)
[‘False’, ‘None’, ‘True’, ‘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’]