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个父类的主要内容,如果未能解决你的问题,请参考以下文章

python 多重继承,继承的几个父类都需要传递参数,怎么在子类计算出父类传递的参数总和呢?

说说 Python 的继承

理解js继承的6种方式

python中的继承关系详解

python中的继承关系详解

python 继承