Python多继承,Python继承,class A :


class A :    def __init__(self) :        self.a = 1    def print_me(self) :        print 'A: ' + str(self.a)class B :    def __init__(self) :        self.b = 2    def print_me(self) :       print 'B: ' + str(self.b)class C :    def __init__(self) :        self.c = 3    def print_me(self) :        print 'C: ' + str(self.c)class D(A,B,C) :    def __init__(self) :        A.__init__(self)        B.__init__(self)        C.__init__(self)        self.d = 4    def printme(self) :      A.print_me(self)      B.print_me(self)      C.print_me(self)      print 'D: '+str(self.d)d = D()d.print_me()d = D()d.print_me()

评论关闭