isinstance
class A(object): pass obj = A() isinstance(obj, A)
#检查obj对象是否是A类的对象
issubclass
class A(object): pass class B(A): pass issubclass(B, A)
#检查B类是否,是A类的子类
2024-02-18 20:15:52
class A(object): pass obj = A() isinstance(obj, A)
#检查obj对象是否是A类的对象
class A(object): pass class B(A): pass issubclass(B, A)
#检查B类是否,是A类的子类