博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python中的super函数
阅读量:582 次
发布时间:2019-03-11

本文共 231 字,大约阅读时间需要 1 分钟。

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

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

转载地址:http://kdctz.baihongyu.com/

你可能感兴趣的文章