父类定义统一化pay接口方法, 子类必须实现这个方法
from abc import ABCMeta, abstractmethod class Payment(metaclass=ABCMeta): @abstractmethod def pay(self): pass class Alipay(Payment): def pay(self): print('阿里pay') class AA(Payment): def fukuan(self): print('没有调用pay方法') alipay = Alipay() alipay.pay() aa = AA() aa.fukuan() # 报错