if not isinstance 用来判断object的类型是不是我们指定的类型
1.判断a是不是浮点型
a=2
if not isinstance(a,float):
raise TypeError("wrong")
2.判断b是不是tuple
b=[1,2,3]
if not isinstance(b,tuple):
raise TypeError("not tuple")
if not isinstance 用来判断object的类型是不是我们指定的类型
1.判断a是不是浮点型
a=2
if not isinstance(a,float):
raise TypeError("wrong")
2.判断b是不是tuple
b=[1,2,3]
if not isinstance(b,tuple):
raise TypeError("not tuple")