【发布时间】:2025-12-31 14:50:16
【问题描述】:
我无法理解这段代码 sn-p。
class First():
def __init__(self):
super(First, self).__init__()
print("first")
class Second():
def __init__(self):
super(Second, self).__init__()
print("second")
class Third(Second, First):
def __init__(self):
super(Third, self).__init__()
print("third")
Third();
输出是:
first
second
third
似乎每个构造函数都以基类First.__init__()然后Second.__init__()的相反顺序调用super(Third, self).__init__() 这个语句是如何工作的。
【问题讨论】:
标签: python-3.x multiple-inheritance