def __init__(self): super().__init__() 这两句有什么用?
时间: 2024-01-10 15:19:06 浏览: 30
这两句代码是Python中的继承语法,用于调用父类的构造函数。在这个例子中,子类的构造函数需要继承父类的构造函数,以便在创建子类对象时能够正确地初始化父类的属性。其中,super()函数返回一个临时对象,该对象可以调用父类的方法。在这个例子中,super().__init__()调用了父类的构造函数,以便正确地初始化父类的属性。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)