【Python学习笔记】变量、常量、空值

1、首先Python是不需要定义变量的,当然也不需要指定数据类型,所以Python中的变量是可以付任意类型的值的。本质是改变变量的指向

# python is  dynamic language,Variables can be assigned arbitrarily
# it is different from C/Java/C++/C#
# = is not ==

a=123 # a is a Integer
a=a+1
a+=1
print a

a='abc' # a is a String
print a

if a=='abcd':
    print a
else:
    print a + "!='abcd'"

运行效果:150627_Ohex_2913386.png

2、字符串

创建字符串变量的三个步骤(对象化)

# Create a String  variable============>create String memory, create variable, variable point memory

a='abc'           # include 3 steps
b=a               # include 2 steps
a='ABC'           # include 2 steps
print b

3、常量

python语言中没有绝对的”常量“,我们通常将常量全部大写来标记该变量是常量

# constant
# All capital variable names is Constant defaultly

PI=3.1415926
print PI

4、运算

常见运算有+加,-减,*乘,/除,%取余,**幂,//整除

5、空值None

# None
# None is not 0

 

 

 

转载于:https://my.oschina.net/MasterLi161307040026/blog/745783

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值