class A(object): def __init__(self, a): print '__init__ A', str(a) self.A = a class B(A): def __init__(self, a, b): super(B, self).__init__(a) print '__init__B', str(b) self.B = b class C(A): def __init__(self, a, c): super(C, self).__init__(a) print '__init__C', str(c) self.C = c class D(B, C): def __init__(self, a, b, c): super(D, self).__init__(a, b, c) print '__init__D', str(d) self.D = d shanghe = D('x', 'y', 'z', 'k')
Traceback (most recent call last):
File "code", line 24, in <module>
shanghe = D('x', 'y', 'z', 'k')
TypeError: __init__() takes exactly 4 arguments (5 given)
请教这份代码错在哪里?
清波
相关分类