class A:标签:MyAdapter,adt,obj,python,适配器,模式,cost,self,def From: https://www.cnblogs.com/CJTARRR/p/17591310.html
def cost(self):
print('cost a')
class B:
def cost(self):
print('cost b')
class MyAdapter:
def __init__(self, obj):
self.obj = obj
def pay(self):
self.obj.cost()
adt_a = MyAdapter(A())
adt_a.pay()
adt_b = MyAdapter(B())
adt_b.pay()