[英]GET() takes exactly 2 arguments (4 given)
I have a web.py application with following server code. 我有一个带有以下服务器代码的web.py应用程序。
import web
import mod1
urls = (
'/(\w*)/(c|r|u|d)/(.*)', '\\1.\\2',
)
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
mod1.py
contains mod1.py
包含
class c:
def POST(self):
return "C"
class d:
def DELETE(self):
return "d"
class u:
def POST(self):
return "u"
class r:
def GET(self, _id):
return "v={0}".format(_id)
Now requesting http://.../mod1/r/3
returns GET() takes exactly 2 arguments (4 given)
. 现在请求
http://.../mod1/r/3
返回GET() takes exactly 2 arguments (4 given)
。
What is the problem here? 这里有什么问题?
Your URL configuration has 3 parameters ( (\\w*)
, (c|r|u|d)
and (.*)
). 您的URL配置具有3个参数(
(\\w*)
, (c|r|u|d)
和(.*)
)。 Plus the self
argument for methods, that makes 4 arguments. 加上方法的
self
参数,即有4个参数。
Adjust your GET
method to accept all parameters: 调整您的
GET
方法以接受所有参数:
def GET(self, param1, operation, id_):
These match each of the regular expression capturing groups; 这些匹配每个正则表达式捕获组; I guessed at the parameter names for each, you can adjust as needed.
我猜每个参数的名称,可以根据需要进行调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.