Python 类型错误继承
Python TypeError inheritance
首先,如果这个问题看起来与之前提出的一些问题相似,我们深表歉意;但他们没有帮助 me.I 我试图在 child 中使用 parent class。两个 classes 收到相同的输入如下:
parent (PA.py):
class The_Parent():
def __init__(self,in1=None,in2=None,in3=None):
#
# and the rest of codes ...
和 child (CH.py):
class The_Child(The_Parent)
def __init__(self,in1,in2,in3):
The_Parent.__init__(self,in1,in2,in3)
#
#
# the rest of code ...
现在,主要功能:
# import requirements and assigning the variables (in1, in2, and in3)
#
obj = CH.The_Child(in1,in2,in3)
#
#
我得到的错误是:
TypeError: The_Child() takes 1 positional argument but 3 were given
只是一点,child 和 parent 应该接收相同的变量...
如果你试图调用Parent构造器,你可以使用Python的"super"关键字来调用它,更多参考你可以参考以下link:How to invoke the super constructor?
首先,如果这个问题看起来与之前提出的一些问题相似,我们深表歉意;但他们没有帮助 me.I 我试图在 child 中使用 parent class。两个 classes 收到相同的输入如下:
parent (PA.py):
class The_Parent():
def __init__(self,in1=None,in2=None,in3=None):
#
# and the rest of codes ...
和 child (CH.py):
class The_Child(The_Parent)
def __init__(self,in1,in2,in3):
The_Parent.__init__(self,in1,in2,in3)
#
#
# the rest of code ...
现在,主要功能:
# import requirements and assigning the variables (in1, in2, and in3)
#
obj = CH.The_Child(in1,in2,in3)
#
#
我得到的错误是:
TypeError: The_Child() takes 1 positional argument but 3 were given
只是一点,child 和 parent 应该接收相同的变量...
如果你试图调用Parent构造器,你可以使用Python的"super"关键字来调用它,更多参考你可以参考以下link:How to invoke the super constructor?