python中的demo_python中简单工厂实现demo
1 classBenBen:2 def __init__(self, money):3 """
4 奔奔金融支付5 :param money:支付金額6 """
7 self.money =money8
9 defpay(self):10 print("收到奔奔金融支付金額{0}".format(self.money))11
12
13 classWeChat:14 def __init__(self, money):15 """
16 微信支付17 :param money:支付金額18 """
19 self.money =money20
21 defpay(self):22 print("收到微信支付金額{0}".format(self.money))23
24
25 classZhiFuBao:26 def __init__(self, money):27 """
28 支付寶支付29 :param money:支付金額30 """
31 self.money =money32
33 defpay(self):34 print("收到支付寶支付金額{0}".format(self.money))35
36
37 if __name__ == '__main__':38 channel = input("請選擇支付方式:")39 money = input("請輸入消費金額:")40 if channel == 'WeChat':41 WeChat(money).pay()42 elif channel == 'ZhiFuBao':43 ZhiFuBao(money).pay()44 else:45 BenBen(money).pay()
總結
以上是生活随笔為你收集整理的python中的demo_python中简单工厂实现demo的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ 中文乱码_Visual Stud
- 下一篇: 无法将该对象添加到ldap服务器_LDA