基本请求
import requests response = requests.get('https://httpbin.org/json') print(response.status_code) print(response.json())
POST 请求
data = {'key': 'value'} response = requests.post('https://httpbin.org/post', json=data)
会话管理
session = requests.Session() session.headers.update({'User-Agent': 'MyApp/1.0'})
转载请注明:周志洋的博客 » Python实用技巧-网络请求基础