a = 200
b = 100
c = a + b
d = a - b
e = a * b
f = a / b
print(c, d, e, f)
总结:变量的定义不需要指定类型
a = 200
b = 'str'
c = True
print(type(a), type(b), isinstance(c, bool))
总结:type()函数返回变量的类型;isinstance()函数判断变量是否是某种类型;常见的类型有:int float str list tuple set dict bool
a = 200
b = '100'
c = str(a) + b
d = int(b) + 100
e = float(b) + 100
f = chr(2) + 'c'
g = ord('2')
print(c, d, e, e, f, g)
总结:str()函数将数字转成字符串
int()函数将字符串转成整数
float()函数将字符串转成浮点数
chr()函数将整数转成字符
ord()获取字符的ascii码