takes 3 positional arguments but 4 were given错误
Posted everfight的成长之路
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了takes 3 positional arguments but 4 were given错误相关的知识,希望对你有一定的参考价值。
之前写程序经常会碰到此类问题,确认发现并没有少参数。后来恍然大悟:函数为类下函数,定义时需要添加self参数。
但是!但是!为何Python给self赋值而你不必给self赋值?
创建了一个类MyClass,实例化MyClass得到了MyObject这个对象,
然后调用这个对象的方法MyObject.method(arg1,arg2),
这个过程中Python会自动转为Myclass.mehod(MyObject,arg1,arg2)。
以上是关于takes 3 positional arguments but 4 were given错误的主要内容,如果未能解决你的问题,请参考以下文章
TypeError: take(): argument 'index' (position 1) must be Tensor, not numpy.ndarray
pymysql报错 takes 1 positional argument but 2 were given
Pytho连接数据库TypeError: __init__() takes 1 positional argument but 6 were?
Python-类-函数参数-takes 0 positional arguments but 1 was given
TypeError: __sigmoid() takes 1 positional argument but 2 were given
TypeError: Dense_net() takes 0 positional arguments but 1 was given