takes from 2 to 4 positional arguments but 5 were given 需要怎么处理?
来源:7-9 主流程封装及错误解决调试

gp0102
2020-06-14
def run_main(self, method, url, data=None, header=None):
res=None
if method=='POST':
self.post_main(self,url,data,header)
else:
self.get_main(self, url, data, header)
return res
调用如下:
def go_on_run(self):
res=None
rows_count=self.data.get_case_lines()
for i in range(1,rows_count):
url=self.data.get_url(i)
method=self.data.get_request_method(i)
header=self.data.get_request_header(i)
is_run=self.data.get_is_run(i)
data=self.data.get_data_for_json(i)
print(“第%s 次打印” %(i))
print(method)
print(url)
print(data)
print(header)
print(is_run)
if is_run:
res= self.run_method.run_main(method, url, data, header)
return res
TypeError: get_main() takes from 2 to 4 positional arguments but 5 were given
第1 次打印
Post
https://m.imooc.com/passport/user/login
{‘username’: ‘18513199586’, ‘password’: ‘111111’, ‘verify’: ‘’, ‘referer’: ‘http://m.imooc.com’}
None
是否运行:True
1回答
-
Mushishi
2020-06-14
你这个一看就是参数个数不对呀,你看你方法需要几个,然后你传递进去了几个。那么大的错误都没看见啊
00
相似问题