Python的标识符命名规则

标识符,变量名,函数名,类名的统称
命名规范
1.只能包含字母、数字、下划线、并且不能以数字开头
2.不能与系统关键字、模块名相同
>>> 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']
3.严格区分大小写
4.尽量使用有意义的英文单词
5.多个单词之间使用下划线连接
变量
声明:取一个名字,给一个值

猜你喜欢

转载自blog.csdn.net/lu962820662/article/details/123528875