多继承实现

project.py

from Child import  Child
def main():
    c = Child(300,100)
    print(c.money,c.faceValue)
    c.play()
    c.func()
if __name__ == "__main__":
    main()

Child.py

from Father import Father
from Mother import Mother
class Child(Father,Mother):
    def __init__(self,money,faceValue):
        Father.__init__(self,money)
        Mother.__init__(self,faceValue)

 

Father.py

class Father(object):
    def __init__(self,money):
        self.money = money
    def play(self):
        print("play")
    def func(self):
        print("func")

Mother.py

class Mother(object):
    def __init__(self,faceValue):
        self.faceValue = faceValue
   
    def play(self):
        print("play")
    def func(self):
        print("func2")

猜你喜欢

转载自blog.csdn.net/qq_41856814/article/details/89385361