【发布时间】:2022-01-25 18:42:59
【问题描述】:
我是 Python 新手。有人可以帮我解决这个错误吗?
我的代码如下,
class First:
def passThisArgs(self, a, b, c):
return Second(self, a, b, c)
class Second:
def __init__(self, a, b, c):
print 'Values are :\n', a, b, c
newObj = First()
a = 5
b = 6
c = 7
newObj.passThisArgs(a, b, c)
我收到此错误:
Traceback (most recent call last):
File "/root/PycharmProjects/abc.py", line 13, in <module>
newObj.passThisArgs(a, b, c)
File "/root/PycharmProjects/abc.py", line 3, in passThisArgs
return Second(self, a, b, c)
TypeError: __init__() takes exactly 4 arguments (5 given)
我在 Linux 中使用 python 2.7。
【问题讨论】: