python 继承2个父类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 继承2个父类相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
class father(object):
def __init__(self,tail,heav):
self.tail=tail
self.heav=heav
class mother(object):
def __init__(self,like,eat):
self.like=like
self.eat=eat
#class xiaoming(mother):
pass
class xiaoming(father,mother):
def init(self,father_tail,father_heav,mother_like,mother_eat):
father.init(self,father_tail,father_heav)
mother.init(self,mother_like,mother_eat)
xm=xiaoming(‘father_178‘,‘father_75‘,‘mother_like‘,‘mother_eat‘)
print "this is father self:",xm.tail,xm.heav
print "this is mother self:",xm.like,xm.eat
以上是关于python 继承2个父类的主要内容,如果未能解决你的问题,请参考以下文章