其他分享
首页 > 其他分享> > isinstance and issubclass

isinstance and issubclass

作者:互联网

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类的子类

  

标签:obj,object,issubclass,pass,isinstance,class
来源: https://www.cnblogs.com/Nolover/p/10983343.html