img = ImageLib()
init = img.grayscale(file='something.jpg')
img.diff(init=init, file='another.jpg')
它给错误说:Python:为什么当我明确地给出它两个时,它至少需要2个参数(1个给出)?
TypeError: diff() takes at least 2 arguments (1 given)
但我给它两个参数!!!!!为什么发生这种情况?
img = ImageLib()
init = img.grayscale(file='something.jpg')
img.diff(init=init, file='another.jpg')
它给错误说:Python:为什么当我明确地给出它两个时,它至少需要2个参数(1个给出)?
TypeError: diff() takes at least 2 arguments (1 given)
但我给它两个参数!!!!!为什么发生这种情况?
我猜你的功能签名有问题。虽然您给了它两个参数,但回溯实际上意味着函数需要2 位置 参数。也许你的关键字参数一个不匹配的位置参数名称:
>>> def foo(a, b, c='foo'):
... pass
...
>>> foo(a="cat", b="bar")
>>> foo(1, c="bar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: foo() takes at least 2 arguments (2 given)
从技术上讲,它只是2 需要参数。在python3中,你可以有必需的关键字(即非位置)参数。看评论。
你可以发布完整的追溯? – mgilson