一、isinstance和issubclass
1.isinstance(obj,cls)检查是否obj是否是类 cls 的对象
class Foo(object): passobj=Foo()print(isinstance(obj, Foo))
输出
True
2.issubclass(sub, super)检查sub类是否是 super 类的派生类
class Foo(object): passclass Bar(Foo): passprint(issubclass(Bar, Foo))