1、super()
主要用于类的多继承中,用来查找并调用父类的方法。
当父类的名字修改后,子类中相应的名字也要进行修改。为了避免该问题,可通过super()解决。
2、super函数语法
super(type,object-or-type)
3、参数
type — 类,一般是类名;
object-or-type — 类,一般是 self;
4、返回值:无
5、使用
class parent:
def fun1(self,message):
print(message)
class child(parent):
def fun2(self,message):
super(child,self).fun1(message)
>>> child().fun2('hello')
hello