1 # 太爷爷 -> 爷爷 -> 爸爸 -> 儿子 2 # 单继承 : 一个父类对应一个子类 3 # 多重继承 : 子类有父类,父类有父类 。。。。 4 class YeYe(): 5 def __init__(self, house): 6 self.house = house 7 self.__wan = "古董" 8 def merry(self): 9 print("爷爷和奶奶结婚了") 10 class Father(YeYe): 11 def __init__(self, house, car): 12 YeYe.__init__(self, house) 13 self.car = car 14 def merry(self): 15 # YeYe.merry(self) 16 print("爸爸和妈妈结婚了") 17 def work(self): 18 print("爸爸上班") 19 class Son(Father): 20 def __init__(self, house, car, computer): 21 Father.__init__(self, house, car) 22 self.computer = computer 23 def merry(self): 24 Father.merry(self) 25 print("就找女朋友,不结婚") 26 27 son1 = Son("大房子", "二手奥拓", "dell") 28 print(son1.house, son1.car, son1.computer) 29 son1.merry()