【发布时间】:2017-05-13 16:58:04
【问题描述】:
我是 python 新手。我试图了解 python 多重继承中的super() 功能。
class B():
def __init__(self):
print("__init__ of B called")
self.b = "B"
class C():
def __init__(self):
print("__init__ of C called")
self.c = "C"
class D(B, C):
def __init__(self):
print("__init__ of D called")
super().__init__()
def output(self):
print(self.b, self.c)
d = D()
d.output()
我收到以下错误:
AttributeError: 'D' object has no attribute 'c'
【问题讨论】:
标签: python python-3.x super