missing 1 required positional argument: 'self'
时间: 2023-11-03 21:04:57 浏览: 330
python类的实例化问题解决
5星 · 资源好评率100%
This error message typically occurs when a method or function is being called without passing the required argument(s). In this case, the required argument is 'self', which refers to the instance of the class.
To fix this error, make sure that you are calling the method or function on an instance of the class and passing 'self' as the first argument. For example:
class MyClass:
def my_method(self, arg1):
# do something with arg1
# create an instance of the class
my_instance = MyClass()
# call the method on the instance and pass the required argument
my_instance.my_method(arg1_value)
阅读全文