📅  最后修改于: 2020-09-20 04:13:56             🧑  作者: Mango
issubclass()
的语法为:
issubclass(class, classinfo)
issubclass()
具有两个参数:
issubclass()
返回:
class
是某个类的子类或元组的任何元素,则为True
False
class Polygon:
def __init__(polygonType):
print('Polygon is a ', polygonType)
class Triangle(Polygon):
def __init__(self):
Polygon.__init__('triangle')
print(issubclass(Triangle, Polygon))
print(issubclass(Triangle, list))
print(issubclass(Triangle, (list, Polygon)))
print(issubclass(Polygon, (list, Polygon)))
输出
True
False
True
True
重要的是要注意,类被视为自身的子类。