TypeError: show_img() takes 1 positional argument but 3 were given
时间: 2023-11-07 21:17:00 浏览: 32
这个错误表示在调用函数 show_img() 时,给了3个参数,但是该函数只接受1个参数。你需要检查一下是不是在调用该函数时,误传了多余的参数。你可以检查一下 show_img() 函数的定义,看看它需要哪些参数,并且确认你是否传递了正确的参数。如果你仍然无法解决问题,请提供更多的代码和错误信息,以便我更好地帮助你。
相关问题
TypeError: __init__() takes 1 positional argument but 3 were given
This error message is raised when you are trying to create an instance of a class with more arguments than the constructor method (__init__()) is expecting.
For example, if you have a class named "Person" that takes only one argument in its constructor method, but you pass three arguments while creating an instance of that class, you will get this error.
Here's an example:
```
class Person:
def __init__(self, name):
self.name = name
person1 = Person("John", 25, "Male")
```
In the above example, the Person class expects only one argument, which is the name of the person. However, while creating an instance of that class, we are passing three arguments - name, age, and gender. Hence, we get the TypeError: __init__() takes 1 positional argument but 3 were given error.
To fix this error, you need to make sure that the number of arguments you pass while creating an instance of a class matches the number of arguments expected by the constructor method.
TypeError:__init__ takes 1 positional argument but 5 were given
这个错误通常是因为在类的初始化函数中传递了错误的参数数量。在你提供的引用中,有三个例子都涉及到了这个错误。其中一个例子中,类的初始化函数中将init拼写成了int,也导致了这个问题。如果你遇到了这个错误,你需要检查类的初始化函数中传递的参数数量是否正确,并且确保没有拼写错误。如果你仍然无法解决这个问题,你可以查看相关文档或者寻求帮助。