用于调用父类(超类)的一个方法
在类的继承中,如果重定义某个方法,该方法会覆盖父类的同名方法,但有时,我们希望能同时实现父类的功能,此时可以用 super() 函数实现
实例:
class A: def add(self, x): y = x + 2 print(y) class B(A): def add(self, x): super().add(x) b = B() b.add(2) # 4