Python 变量定义规范

时间:2026-02-15 02:03:42

1、name=“Alex Li”

name--变量名(标识符)

Alex Li--变量值

Python 变量定义规范

1、变量名只能是:字母、数字或下划线的组合。

Python 变量定义规范

2、变量名的第一个字符不能是数字。

Python 变量定义规范

3、以下关键字不能声明为变量:

and,as,assert,break,class,continue,defdel,elif,else,except,finally,for,from,global,if,import,in,is,lambda,not,for,pass,print,raise,returm try,while,with,yield.

Python 变量定义规范

1、驼峰体

AgeOfOldboy

Python 变量定义规范

2、下划线

age_of_oldboy

Python 变量定义规范

1、在Python中没有一个专门的的语法代表常量,程序员约定俗成的用变量名全部大写代表常量。

Python 变量定义规范

© 2026 手抄报圈
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com