iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python变量的作用与定义规则
  • 834
分享到

python变量的作用与定义规则

变量定义规则 2023-01-31 02:01:25 834人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

变量的作用: Variables are used to store infORMation to be referenced and manipulated in a computer program. They also p

 变量的作用:
     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的自有变量(不要以这种变量命名)。

--结束END--

本文标题: python变量的作用与定义规则

本文链接: https://www.lsjlt.com/news/186557.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作