Python类的继承顺序__mro__
class A:
def test(self):
print('print from A')
pass
class B(A):
# def test(self):
# print('print from B')
pass
class C(A):
def test(self):
print('print from C')
pass
class D(B):
# def test(self):
# print('print from D')
pass
class E(C):
# def test(self):
# print('print from E')
pass
class F(D,E):
# def test(self):
# print('print from F')
pass
f=F()
print(F.__mro__)
f.test()
输出:
class A:
def test(self):
print('print from A')
pass
class B(A):
# def test(self):
# print('print from B')
pass
class C(A):
def test(self):
print('print from C')
pass
class D(B):
# def test(self):
# print('print from D')
pass
class E(C):
# def test(self):
# print('print from E')
pass
class F(D,E):
# def test(self):
# print('print from F')
pass
f=F()
print(F.__mro__)
f.test()
写入自己的博客中才能记得长久