isinstance()和type()用来确定数据类型
isinstance()和type()的主要区别
isinstance()考虑继承关系
type()不考虑继承关系
【sample】
In [1]: class A(object):
pass
In [2]: class B(A):
pass
In [3]: b = B()
In [4]: type(b) In [7]: type(b) == B
Out[4]: __main__.B Out[7]: True
In [5]: isinstance(b, B) In [8]: type(b) == A
Out[5]; True Out[8]: False
In [6]: isinstance(b, A)
Out[6]: True