class log shel 数字 shell trac brush 好书
- #变量
- level=10
- ptint(level)
- 变量定义规则
- 1 变量名只能是字母、数字或下划线的任意组合
- 2 变量名第一个字符不能是数字
- 3 一些Python中的常用词不能为变量名
- 最好书写成下划线形式
- age_of_oldboy=50
- num_of_student=70
- #常量
- 比如说年龄
- AGE_OF_OLDBOY=50
- 我们不想让其改变#其实一样可以改变
- ######
- x=1
- x=10
- 定义一个变量有三个特征
- id:id(x) 看存储位置
- type:type(x) 看文件类型
- value:x 看值
- ################
- >>> x=10
- >>> x
- 10
- >>> id(x)
- 1513141600
- >>> type(x)
- <class ‘int‘>
- >>>
- ################
- 注意:python中的变量名没有储存值的功能
- 变量名与变量值只是一种绑定关系
- ################
- >>> y=x
- >>> y
- 10
- >>> id(y)
- 1513141600
- >>> type(y)
- <class ‘int‘>
- >>>
- ################
- >>> del x #卸载x
- >>> x
- Traceback (most recent call last):
- File "<pyshell#9>", line 1, in <module>
- x
- NameError: name ‘x‘ is not defined
- >>> y
- 10
- >>>
- #################
python变量
来源: http://www.bubuko.com/infodetail-2290921.html