#!/usr/bin/env python # -*- coding:utf-8 -*- # isinstance(obj,cls) #用于判断obj对象是否由cls这个类实例化出来的 #若实例化对象的类继承了父类,判断对象isintance父类也返回True class Foo: def __init__(self,name): self.name = name f = Foo('jerry') print(isinstance(f,Foo)) #True # issubclass(cls,classinfo) #用于判断cls类是否是classinfo的子类 class Foo: def __init__(self,name): self.name = name class Bar(Foo): pass f1 = Bar('Jerry') print(isinstance(f1,Foo)) #True print(issubclass(Bar,Foo)) #True