简单地解释overwrite

class Dog(object):
    def __init__(self, name):
        self.name = name

    def run(self):
        print("Dog is running")

class WhiteDog(Dog):
    def __init__(self, name):
        self.name = name

    def run(self):
        print("white dog is running")

dog = Dog("a")
dog2 = WhiteDog("b")
dog.run()
dog2.run()

posted @ 2019-12-18 16:25  一条图图犬  阅读(405)  评论(0编辑  收藏  举报