面向对象(五)super

时间:2023-03-10 02:27:02
面向对象(五)super

super方法只是为了执行继承父级的init方法,若要详细,请参考别人的博客

class a(object):
def __init__(self):
print("aINIT") def a1(self):
print("a") class b(a):
def __init__(self):
super(b, self).__init__()
print("bINIT") def b1(self):
print("b") b().a1()
>>>aINIT
>>>bINIT
>>>a

方法2:

面向对象(五)super