BZ易风

导航

 
 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@
飞

  

posted on 2019-08-13 14:43  BZ易风  阅读(158)  评论(0编辑  收藏  举报