TypeError: __call__() takes 1 positional argument but 2 were given
时间: 2023-10-16 22:14:50 浏览: 56
This error occurs when you try to call a function or method that expects only one argument, but you pass in two or more arguments instead.
For example, if you define a function like this:
```
def my_function(x):
print(x)
```
and then try to call it with two arguments:
```
my_function(1, 2)
```
you will get the TypeError: __call__() takes 1 positional argument but 2 were given error.
To fix this error, make sure that you are passing in the correct number of arguments to the function or method. If the function is designed to take multiple arguments, you may need to adjust the function signature to accept multiple arguments.
相关问题
TypeError: __init__() takes 1 positional argument but 2 were given
This error occurs when you try to call a function or method with more arguments than it is expecting. In this case, it looks like you are trying to initialize an object by calling its `__init__()` method with two arguments, but it is only expecting one.
To fix this error, you need to check the documentation for the object you are trying to initialize and make sure you are passing the correct number of arguments to its `__init__()` method. If you are unsure, you can also try printing out the object and its attributes to see what arguments it requires.
return _get_backend_mod().show(*args, **kwargs) TypeError: __call__() takes 1 positional argument but 2 were given
这个错误通常出现在调用一个没有定义参数的函数时,而给了它一个参数。也可能是传递参数的方式不正确。
建议你检查一下你的代码,看看是否在调用函数时传递了多余的参数,或者传递参数的方式是否正确。你可以尝试使用更具体的参数名来调用函数,例如:
```
function_name(param_name=value)
```
这样可以避免参数位置不正确的问题。如果问题仍然存在,你可以尝试查看函数定义,确认参数的数量和名称是否正确。