相关疑难解决方法(0)

如何调用超级构造函数?

class A:
    def __init__(self):
        print("world")

class B(A):
    def __init__(self):
       print("hello")

B()  # output: hello
Run Code Online (Sandbox Code Playgroud)

在我使用超级构造函数的所有其他语言中隐式调用.如何在Python中调用它?我希望,super(self)但这不起作用.

python inheritance constructor class superclass

330
推荐指数
6
解决办法
24万
查看次数

标签 统计

class ×1

constructor ×1

inheritance ×1

python ×1

superclass ×1