def URLRequest(url, params, method="POST"):
h = Http()
res, content = h.request(url, method, urllib.urlencode(params))
r = {}
r['res'] = res
r['content'] = content
return r
假设我想将{"key":"value"}
发送到网址(REST)。这个功能是正确的吗?
答案 0 :(得分:2)
如果有效则是正确的。你可以缩短它:
def URLRequest(url, params, method="POST"):
res, content = Http().request(url, method, urllib.urlencode(params))
return {'res':res, 'content':content}