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'"
运行效果:
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