TypeError: __call__() takes 1 positional argument but 2 were given
时间: 2023-10-16 18:14:50 浏览: 200
第十一天 04魔法方法【千锋Python人工智能学院】1
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.
阅读全文