python变量的作用与定义规则

发布时间:2020-08-06 10:46:10 作者:梦想不遥远
来源:网络 阅读:1025
 变量的作用:
     Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

     变量用于存储计算机程序中引用和操作的信息。它们还提供了用描述性名称标记数据的方法,因此读者和我们自己可以更清楚地理解我们的程序。将变量看作容器来保存信息是很有帮助的。他们唯一的目的是在内存中标记和存储数据。这些数据可以在整个程序中使用。

     变量定义规则:

 变量名只能是 字母、数字或下划线的任意组合
 变量名的第一个字符不能是数字
 以下关键字不能声明为变量名['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']
     模块名,包名 :小写字母, 单词之间用_分割。
 类名:首字母大写。
 全局变量: 大写字母, 单词之间用_分割。
 普通变量: 小写字母, 单词之间用_分割。
 函数: 小写字母, 单词之间用_分割。
 实例变量: 以_开头,其他和普通变量一样 。
 私有实例变量(外部访问会报错): 以__开头(2个下划线),其他和普通变量一样 。
 专有变量: __开头,__结尾,一般为python的自有变量(不要以这种变量命名)。
推荐阅读:
  1. PHP 变量规则
  2. haproxy定义规则

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python 变量 作用

上一篇:Flask中的endpoint是什么

下一篇:怎么选择usb打印机端口

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》