Posted on
2021-04-27 16:02MissRong
阅读(44)
评论(0)
收藏举报
Python(二十一)多态
class A:
def fun(self):
print("A类的方法")
class B:
def fun(self):
print("B类的方法")
class C:
def test(self, obj):
obj.fun()
if__name__ == "__main__":
a = A()
b = B()
c = C()
#鸭子类型
c.test(a)