Python-基础数据类型,,Numbes:int


Numbes:

integer

float point

complex: e.g. (-5+4j)

Strings:

单引号双引号用法一致,

三个单引号或三个双引号表示多行字符串

‘‘‘first line

second line,

third line.

‘‘‘

raw strings:让转义字符变为一般字符

r‘Newlines are indicate by \n‘,打印结果为Newlines are indicate by \n

一旦创建一个string,就不能改变它。

format方法

age = 25

name = ‘Swaroop‘

print(‘{0} is {1} years old‘.format(name,age))

结果:Swaroop is 25 years old

不需要声明或定义变量的数据类型

缩进:

python通过缩进来区分每一组语句,而不是像C++中的大括号{}

缩进可以用Tab或空格,一般使用4个空格

Python-基础数据类型

评论关闭