Python 变量定义规范

2025-10-07 15:30:44

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 变量定义规范

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢