python 类多重继承问题
Posted 五等码农
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 类多重继承问题相关的知识,希望对你有一定的参考价值。
# _*_ coding: utf-8 _*_
__author__ = ‘pythonwu‘
__date__ = "2018/7/2 14:50"
class A():
def getValue(self):
print(‘return value of A ‘)
def show(self):
print(‘I can show A‘)
class B(A):
def getValue(self):
print(‘return value of B‘)
class C(A):
def getValue(self):
print(‘return value of C‘)
def show(self):
print(‘I can show C‘)
class D(B,C):
pass
d = D()
d.show()
d.getValue()
from pprint import pprint
pprint(D.mro())
I can show C
return value of B
[<class ‘__main__.D‘>,
<class ‘__main__.B‘>,
<class ‘__main__.C‘>,
<class ‘__main__.A‘>,
<class ‘object‘>]
以上是关于python 类多重继承问题的主要内容,如果未能解决你的问题,请参考以下文章