0%
简介
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
class abb: print('class 只要里面有print,不用走主函数入口,直接就运行。实例化class之后,print反而不执行。')
class Alipay: a = 'alipay_a' def paying(self,money): print('支付宝支付')
class Apppay: a = 'apppay_a' print('苹果的类已经运行了。') def pay(self,money): print('苹果支付')
class payment: print(' 手动抛出异常 1 。') a = 'payment_a' b = 'payment_b' def pay(self): print(' 手动抛出异常 2 。') raise NotImplementedError
print('****************\n') def pay(payment,money): print(payment.a) payment.pay(money) print('****************\n')
if __name__=='__main__': b = Apppay() pay(b,100)
|