标签:错误 blog 方法 argument 参数 python osi 创建 self
之前写程序经常会碰到此类问题,确认发现并没有少参数。后来恍然大悟:函数为类下函数,定义时需要添加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错误
标签:错误 blog 方法 argument 参数 python osi 创建 self
原文地址:http://www.cnblogs.com/everfight/p/python_class.html