Python 'takes exactly 1 argument (2 given) 'Python error, pythonargument
When Python is a beginner, it defines the parameters received by urlConfig. When parameters are passed normally, an extra parameter error occurs,
After defining the class function, "'Takes exactly 1 argument (2 given) 'Python error" appears during the call ".
After the Interesting 'takes exactly 1 argument (2 given) 'Python error is queried, when an instance is used to call its class method in python, it is equivalent to adding itself as the first parameter in the call. As follows:
A. method (k)
It is equivalent:
A. method (a, k)
Therefore, when defining a function, you need to define the first parameter in the function as self, for example:
Class Person ():
Def method (self, k ):
...
If you want to call a static function, you can add "@ staticmethod" above the defined function to identify it.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!