检查obj是否是类cls的对象
class Foo(): print 'foo'demo=Foo()print isinstance(demo,Foo)
检查sub类是否是 super 类的派生类
class Foo(): print 'foo'class sub_Foo(Foo): print 'sub_Foo'print issubclass(sub_Foo,Foo)
本文共 250 字,大约阅读时间需要 1 分钟。
class Foo(): print 'foo'demo=Foo()print isinstance(demo,Foo)
class Foo(): print 'foo'class sub_Foo(Foo): print 'sub_Foo'print issubclass(sub_Foo,Foo)
转载于:https://www.cnblogs.com/yanhongjun/p/5294269.html