python2、python3 的requests 库返回不同结果

问题现象:
写了一个脚本来获取服务端返回的http headers,结果发现python2、python3 返回内容差很多,记录一下,下次使用可以两个环境都跑【请求代码完全一样,使用了requests 库的get 方法】

首先python3 返回的http headers 如下

{'Date': 'Wed, 08 Jan 2020 01:29:42 GMT', 'Content-Type': 'application/javascript; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'waf/4.18.2-2.el6', 'Content-MD5': 'fHNXqB1dNxJrWb/Hutl8hg==', 'Last-Modified': 'Mon, 06 Jan 2020 05:07:25 GMT', 'x-ms-request-id': '2dc76298-f01e-002f-5345-c52b2f000000', 'x-ms-version': '2009-09-19', 'x-ms-lease-status': 'unlocked', 'x-ms-blob-type': 'BlockBlob'}

python2 返回的http headers 如下

{'x-ms-version': '2009-09-19', 'Strict-Transport-Security': 'max-age=2592000', 'x-ms-blob-type': 'BlockBlob', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'HYB_SH=6733159b58360064c26d15480d3bae032f; Expires=Wed, 08-Jan-20 01:41:40 GMT; Path=/, HMF_CI=befb27afec5475742a14966ee0250364fcf8f28ed24b2adb8e2d4c92afc2fb144c; Expires=Fri, 07-Feb-20 01:41:35 GMT; Path=/', 'x-ms-request-id': '2dc76298-f01e-002f-5345-c52b2f000000', '\xe2\x80\x98Access-Control-Allow-Origin\xe2\x80\x99': '\xe2\x80\x98*\xe2\x80\x99', 'X-Via': '1.1 qinzhoudianxin67:0 (Cdn Cache Server V2.0), 1.1 nxiazai14:4 (Cdn Cache Server V2.0), 1.1 ddxxz134:4 (Cdn Cache Server V2.0)', 'Content-MD5': 'fHNXqB1dNxJrWb/Hutl8hg==', 'X-Ws-Request-Id': '5e15334f_ddxxz134_26517-40876', 'Last-Modified': 'Mon, 06 Jan 2020 05:07:25 GMT', 'Connection': 'keep-alive', 'Date': 'Wed, 08 Jan 2020 01:41:35 GMT', 'Server': 'waf/4.18.2-2.el6', 'Content-Type': 'application/javascript; charset=utf-8', 'Age': '1', 'x-ms-lease-status': 'unlocked'}

你可能感兴趣的:(python)