How to solve python error: TypeError: __init__() takes exactly 4 arguments (5 given)

How to solve python error: TypeError: __init__() takes exactly 4 arguments (5 given)

我是 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。

您不会将“self”传递给另一个 class。 Python 将创建一个全新的对象并将其作为 self 参数自动传递给 __init__。所以:

        return Second(a,b,c)