Python之requests模块获取请求头和报响应头


import requests
from baseDatas import userAgents
data = {"a":2, "b":"abc"}
headers = {"User-Agent": userAgents[2]}
res = requests.post(url, data=data, headers = headers)
print("请求头:%s" %res.request.headers)
print("响应头:%s" %res.headers)