python 继承基础

 1 class annamal:
 2     def chi(self):
 3         print(self.name + '')
 4     def he(self):
 5         print(self.name + '')
 6 
 7 class dog(annamal):
 8     def __init__(self,name):
 9         self.name = name
10     def bark(self):
11         print(self.name+' auhhh...')
12 pp = dog('AA')
13 pp.chi()
14 pp.he()
15 pp.bark()

 python 多继承

 1 class Alex:
 2     def f1(self):
 3         print('alex')
 4 
 5 class A(Alex):
 6     def f(self):
 7         print('A')
 8 class B(Alex):
 9     def f(self):
10         print('B')
11 class C(A):
12     def f(self):
13         print('C')
14 class D(B):
15     def f(self):
16         print('D')
17 class E(C,D):
18     def f(self):
19         print('E')
20 obj = E()
21 obj.f1()

 

posted @ 2017-02-23 23:20  Erick-LONG  阅读(231)  评论(0编辑  收藏  举报