..

python 使用 urllib2 发送 PUT 请求

默认是没法直接设置请求方法为 POST 的,需要重写请求对象得 get_method 方法,让这个方法返回 PUT

request = urllib2.Request("http://example.com", json.dumps({"name":project,"version":branch}),  {'Content-Type': 'application/json'})
request.get_method = lambda: "PUT"