一 .isinstance(obj,cls)和issubclass(sub,super)
class Foo: pass class Bar(Foo): pass obj = Bar() isinstance(obj,cls)检查是否obj是否是类 cls 的对象 print(isinstance(obj, Bar)) # True ,判断是obj对象是否属于Bar这个类 issubclass(sub, super)检查sub类是否是 super 类的派生类 print(issubclass(Bar, Foo)) # True ,#判断Bar类是否属于Foo的子类 print(isinstance([1,2,3],list)) #True