判断变量类型
类型不同,input()返回字符串
‘1’ + 3 '小明考了’+90 报错
type() 判断变量类型
a = 1
b = 1.5
d = ‘hello’
e = True
type(a) →(class ’int’)
type(b) →(class ’float’)
type(d) →(class ’str’)字符串
type(e) →(class ’bool’)
isinstance(值, 类型)
isinstance(1, int) → True
isinstance(1, float) → False
isinstance(‘小明’,float) → False