Python: TypeError: XXX() takes exactly 1 argument (2 given)
2016-12-31 19:07
1451 查看
在调用某一个类A的方法时,出现以下错误:TypeError: XXX() takes exactly 1 argument (2 given)
Python在调用一个实例的方法是,将instance本身也作为一个参数传入,即
调用方法:insA.method_1(k)
其实调用的是:ins_A.method_1(self, k)
因此在类A中定义方法method_1时,必须包含self参数:
method_1(self, input)
Python在调用一个实例的方法是,将instance本身也作为一个参数传入,即
调用方法:insA.method_1(k)
其实调用的是:ins_A.method_1(self, k)
因此在类A中定义方法method_1时,必须包含self参数:
method_1(self, input)
相关文章推荐
- PamIE 和COM调用IE出错: TypeError: getElementById() takes exactly 1 argument (2 given)
- TypeError: takes exactly 1 argument (2 given)
- TypeError: checkcode() takes exactly 1 argument (2 given)
- django中报错TypeError: su() takes exactly 1 argument (2 given)的解决办法
- python安装pbkdf2 遇到错误TypeError: __call__() takes exactly 2 arguments (1 given)
- Python 'takes exactly 1 argument (2 given)' Python error
- python 点滴记录4:TypeError: range() integer end argument expected, got str.
- TypeError: distinct() takes exactly 2 arguments (3 given)
- python 调用super()初始化报错“TypeError: super() takes at least 1 argument”
- Python openpyxl TypeError: __init__() got an unexpected keyword argument 'pivotButton' (and)
- python3-网络编程-TypeError: send() argument 1 must be bytes or buffer, not str异常
- TypeError: __init__() takes exactly 2 arguments (1 given)(已解决)
- python MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") TypeError: __call__() takes exactly 2
- TypeError:__init__() got an unexpected keyword argument 'xxx'
- Python 读写文件 错误TypeError: write() argument must be str, not bytes+
- python 调用super()初始化报错“TypeError: super() takes at least 1 argument”
- Python出现TypeError: file() argument 1 must be encoded string without NULL bytes, not str问题解决
- TypeError: __init__() takes exactly 2 arguments (3 given)
- python-rrdtool创建rrd文件的TypeError: argument 0 must be string 错误
- python安装某模块时出现 TypeError: __call__() takes exactly