功能。。接受0个位置参数,但给出了1个

2024-03-29 04:57:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python新手,我想练习一个父类和派生类。我想用super调用父函数给子类。但我有点错误。代码是

class First:
    def my_func():
        print('first')

class Second(First):
    def my_func1():
        super().my_func()
        print('second')

obj = Second()
obj.my_func1()

Tags: 函数objmydef子类classfirstfunc