# author : yang.cao
# date : 2020.02.12
class Parent:
def __init__(self):
print("Father")
class Son1(Parent):
def __init__(self):
super().__init__()
print("Son1")
class Son2(Parent):
def __init__(self):
super().__init__()
print("Son2")
class Grandson(Son1, Son2):
def __init__(self):
super(Son2, self).__init__() # 按照Son2的父类来继承
print("grandson")
son = Grandson()
print(Grandson.__mro__)
python中的继承测试代码
最新推荐文章于 2021-05-23 16:25:00 发布