super函数用来解决钻石继承。
一、python的继承以及调用父类成员
父类:
class Base(object):
def __init__(self):
print("base init.")
普通方法调用父类:
class Leaf(Base):
def __init__(self):
Base.__init__(self)
print("Leaf init.")
super方法调用父类:
class Leaf(Base):
def __init__(self):
super(Leaf, self).__init__()
print("Leaf init.")