2024-03-29 04:57:11 发布
网友
我是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()
class First: def my_func(self): print('first') class Second(First): def my_func1(self): super().my_func() print('second') obj = Second() obj.my_func1()
相关问题 更多 >
编程相关推荐