1. 作用
用于子类调用父类的方法
2. 操作
# super
class A(object):
def __init__(self):
print('enter A')
print('exit A')
class B(A):
def __init__(self):
print('enter B')
super(B, self).__init__()
print('exit B')
class C(A):
def __init__(self):
print('enter C')
super(C, self).__init__()
print('exit C')
class D(C, B): #
def __init__(self):
print('enter D')
super(D, self).__init__()
print('exit D')
if __name__ == '__main__':
d = D()
# enter D
# enter C
# enter B
# enter A
# exit A
# exit B
# exit C
# enter D