zl程序教程

您现在的位置是:首页 >  后端

当前栏目

简述python变量的命名规则_Python 变量命名规则

Python规则变量 命名 简述
2023-06-13 09:12:02 时间

大家好,又见面了,我是你们的朋友全栈君。

Python 变量命名规则

python 是动态编译语言,不用事先声明类型,赋值即声明。

1. 要具有描述性

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

3.不能是中文

4.不能以数字开头

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

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/134438.html原文链接:https://javaforall.cn