标识符
# 标识符
变量、模块名、函数名、类名
# 标识符的命名规则和规范
规则
由数字、字母和_组成,不能以数字开头
区分大小写
不能使用关键字
and as assert break class continue def del elif else except finally for from False global if import in is lambda nonlocal not None or pass raise return try True while with yield
规范
顾名思义
遵守一定的命名规范
- 小驼峰命名法:第一个单词的首字母小写,然后每个字母的首字母都大写 userNameAndPassword
- 大驼峰命名法:每个个单词的首字母都大写 PersonModel
- 使用下划线连接: user_name_and_password
- 在 python 里的变量、函数和模块名使用下划线连接;python 里的类名用大驼峰命名法
编辑 (opens new window)
上次更新: 2023/12/06, 01:31:48