# 可以使用内置的 issubclass() 检查类继承关系:

>>> class BaseClass: pass
>>> class SubClass(BaseClass): pass

>>> issubclass(SubClass, BaseClass)
True
>>> issubclass(SubClass, object)
True
>>> issubclass(BaseClass, SubClass)
False

关注PythonCN.png


PythonCN
3 声望1 粉丝

感谢订阅,我是大鹏。人生苦短,我用 Python。