class Aoo(): def aoo(self): print("aoo_self") self.doo() #self获取的调用的对象,self.doo再回到原点 def doo(self): print("boo_self") class Coo(): def coo(self): print("Coo_self") class Doo(Aoo,Coo): def doo(self): # super(Doo, self).doo() print("Doo_self") obj = Doo() obj.aoo()
#多继承 class Aoo(): def aoo1(self): print("aoo_self") # self.doo() #self获取的调用的对象,self.doo再回到原点 class Boo(Aoo): def aoo1(self): print("boo_self") class Coo(): def aoo1(self): print("Coo_self") class Doo(Boo,Coo): #多继承是按照继承的顺序先执行左边的,再执行右边的 def aoo1(self): #执行左边的还继承了父类,查找就按照Boo-Aoo都没有的情况下在执行Coo # super(Doo, self).doo() print("Doo_self") obj = Doo() obj.aoo1()
多态:就是一个参数既可以传数字也可以传字母等
class Ca: def __init__(self,f): self.name = 1 self.age = 2 self.f = f print(f) def duotai(self,args): print(self.name,self.age,args) # print(args.name,args.age,args.f) def he(self,ass): print(ass) obj = Ca(121) obj.duotai(123456789) obj.he("www") obj.he(121212)