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

 

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2021-10-31
  • 2022-12-23
  • 2021-07-02
  • 2022-02-21
  • 2021-11-08
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2021-06-03
  • 2021-08-23
  • 2022-12-23
  • 2021-07-17
  • 2021-05-31
相关资源
相似解决方案