# 一、整数(int)

`In [31]: print(type(0))<class ‘int‘>In [32]: print(type(1))<class ‘int‘>In [33]: print(type(2))<class ‘int‘>In [34]: print(type(3))<class ‘int‘>In [35]: print(type(-1))<class ‘int‘>In [36]: print(type(-2))<class ‘int‘>In [37]: print(type(-3))<class ‘int‘>`

# 二、浮点数（小数）(float)

`In [39]: print(type(0.0))<class ‘float‘>In [40]: print(type(0.3))<class ‘float‘>In [41]: print(type(15.6))<class ‘float‘>In [42]: print(type(1.0))<class ‘float‘>In [43]: print(type(-1.45))<class ‘float‘>`

# 三、字符串(str)

`In [44]: print(type(‘2a‘))<class ‘str‘>In [45]: print(type("33"))<class ‘str‘>In [46]: print(type("ab\‘cd"))<class ‘str‘>In [48]: print("2a")2aIn [49]: print("33")33In [50]: print("ab\‘cd")ab‘cd`

`In [51]: print("I\‘m a boy")I‘m a boyIn [52]: print("say \"hello world\"")say "hello world"In [53]: print("print \\")print \`

# 四、布尔值(bool)

`In [56]: print(type(True))<class ‘bool‘>In [57]: print(type(False))<class ‘bool‘>`

# 五、空值(NoneType)

：None

`In [58]: print(type(None))<class ‘NoneType‘>`

# 练习

n = 123

f = 456.789

s1 = ‘Hello, world‘

s3 = r‘Hello, "Bart"‘

s4 = r‘‘‘Hello, Lisa!‘‘‘

python初级 1 数据类型和变量

(0)
(0)

0条