requests如何发送其他请求

乙醇 创建于 8 个月 之前

最后更新时间 2018-09-11

官方文档

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')

我要留言

暂无评论