接口
# class Payment(object):
#
# def pay(self, money):
# raise NotImplementedError
from abc import ABCMeta, abstractmethod
class Payment(metaclass=ABCMeta):
"""abstract method - 接口"""
@abstractmethod
def pay(self, money):
pass
class Alipay(Payment):
"""Alipay 实现了 Payment 接口"""
def pay(self, money):
print(f'支付宝支付 {money} 元!')
class WechatPay(Payment):
"""WechatPay 实现了 Payment 接口"""
def pay(self, money):
print(f'微信支付 {money} 元!')
p = WechatPay()
p.pay(100)
class User(object):
def show_name(self):
pass
class VIPUser(User):
def show_name(self):
pass