class Animal:
def run(self):
pass
class Dog(Animal):
def run(self):
print('狗通常走S型')
class Cat(Animal):
def run(self):
print('猫平时走猫步,偶尔突然加速')
def test(obj):
obj.run()
d = Dog()
c = Cat()
test(d)
test(c)
python 多态
最新推荐文章于 2022-05-16 14:26:43 发布