p y t h o n 中 的 s u p e r 函 数 python中的super函数 python中的super函数

super() 函数是用于调用父类(超类)的一个方法。

class A:
     def add(self, x):
         y = x+1
         print(y)
class B(A):
    def add(self, x):
        super().add(x)
b = B()
b.add(2)  
# j结果:3