class dog(object):
def speak(self):
print("狗叫")
class cat(object):
def speak(self):
print("猫叫")
class Person(object):
def speak(self):
print("人说普通话")
def speak(obj):
obj.speak()
p = Person()
speak(p)
c = cat()
speak(c)
d = dog()
speak(d)
标签:多态性,self,object,print,class,def,speak
From: https://www.cnblogs.com/jiyiran/p/16869190.html