super(class,self).init()
其中class是子类,这段代码的含义是首先找到class的父类,然后将class类的对象转化为父类的对象,让后让这个“被转化”的对象调用自己的__init__()函数。
class child_with_super(father):
def init(self,father_attribute,super_attribute):
super(child_with_super, self).init(father_attribute)
self.super_attribute=super_attribute
本文解析了如何在Python中使用`super(class, self).init()`,即通过子类调用父类的构造函数,实现类的继承初始化。重点讲解了类的实例化过程和super()的作用。
1377

被折叠的 条评论
为什么被折叠?



