查看某个对象是否 这个类实例
是返回True 否则返回False
class Foo(object): pass obj = Foo() class Boo(object): pass print(isinstance(obj, Foo)) print(isinstance(obj, Boo)) ''' True False '''
ojb 是 Foo 实例对象 也是父类 Boo 实例对象
class Foo(object): pass obj = Foo() class Boo(Foo): pass obj = Boo() print(isinstance(obj, Boo)) print(isinstance(obj, Foo)) ''' True True '''