requests如何发送其他请求
乙醇 创建于 almost 7 years 之前
最后更新: less than a minute 之前
阅读数: 154
delete,options,put等类型的请求在requests中均有对应的方法
>>> r = requests.put('http://httpbin.org/put', data = {'key':'value'})
>>> r = requests.delete('http://httpbin.org/delete')
>>> r = requests.head('http://httpbin.org/get')
>>> r = requests.options('http://httpbin.org/get')
也可以使用requests统一的request方法来发送各种请求
r = requests.request('get', 'https://api.github.com/events')
>>> r = requests.request('post', 'http://httpbin.org/post', data = {'key':'value'})
>>> r = requests.request('put', 'http://httpbin.org/put', data = {'key':'value'})
>>> r = requests.request('delete', 'http://httpbin.org/delete')
>>> r = requests.request('head', 'http://httpbin.org/get')
>>> r = requests.request('options', 'http://httpbin.org/get')