Python中的变量命名规则

python

Python 命名规则" title="变量命名规则">变量命名规则

1. 要具有描述性

2.变量名只能是:数字,字母组成,不可以是空格或特殊字符,如:(#?。,¥$*~!&)等

3.不能是中文

4.不能以数字开头

相关推荐:《Python相关教程》

5.保留字符是不能被使用,如下:

['and','as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']

6.变量区分大小写 

常用的命名方法:

phone_number = 13000000000

phoneNumber =  13000000000

以上是 Python中的变量命名规则 的全部内容, 来源链接: utcz.com/z/524330.html

回到顶部