安装命令: pip install httpx
请求方式
GET
import httpx
headers = {'user-agent': 'my-app/1.0.0'}
params = {'key1': 'value1', 'key2': 'value2'}
url = 'https://httpbin.org/get'
r = httpx.get(url, headers=headers, params=params)
POST
r = httpx.post('https://httpbin.org/post', data={'key': 'value'})
PUT
r = httpx.put('https://httpbin.org/put', data={'key': 'value'})
DELETE
r = httpx.delete('https://httpbin.org/delete')