isinstance判断对象是否为类的实例。
n1 = 9 print isinstance(n1,str)
True
class A: pass class B(A): pass a =B() print isinstance(a,A)
True
issubcalss判断类是否为子类
class A: pass class B(A): pass print issubclass(B,A)
True
时间: 2024-10-16 16:43:42
isinstance判断对象是否为类的实例。
n1 = 9 print isinstance(n1,str)
True
class A: pass class B(A): pass a =B() print isinstance(a,A)
True
issubcalss判断类是否为子类
class A: pass class B(A): pass print issubclass(B,A)
True