跳转至

🔥AI副业赚钱星球

点击下面图片查看

郭震AI

42

编辑日期: 2024-11-28 文章阅读:

@author jackzhenguo
@desc 
@date 2019/3/13

42 issubclass父子关系鉴定

In [1]: class undergraduate(Student):
    ...:     def studyClass(self):
    ...:         pass
    ...:     def attendActivity(self):
    ...:         pass

In [2]: issubclass(undergraduate,Student)
Out[2]: True

In [3]: issubclass(object,Student)
Out[3]: False

In [4]: issubclass(Student,object)
Out[4]: True

如果class是classinfo元组中某个元素的子类,也会返回True

In [1]: issubclass(int,(int,float))
Out[1]: True

上一个例子 下一个例子

京ICP备20031037号-1