标签:highlight div $@ code false elf 父类 python2 col
1 class Animal: 2 def eat(self): 3 print("吃") 4 5 def drink(self): 6 print("喝") 7 8 def run(self): 9 print("跑") 10 11 def sleep(self): 12 print("睡") 13 14 class Dog(Animal): 15 def bark(self): 16 print("叫") 17 18 class XiaoTianQuan(Dog): 19 def fly(self): 20 print("飞") 21 22 # def bark(self): 23 # print("像神一样叫") 24 # 25 # # 调用父类bark方法 26 # super().bark() 27 # 28 # # 扩展 29 # print("!@$#@@(*U!(") 30 31 # python2.x的扩展和重写 32 def bark(self): 33 34 print("像神一样叫") 35 36 Dog.bark(self) 37 38 print("@#$@#R@") 39 40 xtq = XiaoTianQuan() 41 xtq.eat() 42 xtq.bark() 43 xtq.fly()
吃 像神一样叫 叫 @#$@#R@ 飞
标签:highlight div $@ code false elf 父类 python2 col
原文地址:https://www.cnblogs.com/yifengs/p/11345826.html