python如何读取Excel文件(python requests响应内容的三种方法)
导读:1、二进制响应内容,以字节的方式访问请求响应体。...
1 、二进制响应内容 ,以字节的方式访问请求响应体 。
对于非文本请求:
>>>r.content b[{"repository":{"open_issues":0,"url":"https://github.com/...2 、JSON响应内容 ,Requests有内置的JSON解码器,处理JSON数据 。
>>>importrequests >>>r=requests.get(https://github.com/timeline.json) >>>r.json() [{urepository:{uopen_issues:0,uurl:https://github.com/...3、原始响应内容 ,可以访问r.raw 。
如果你确实想这么干 ,那请你确保在初始请求中设置了stream=True 。具体的你可以这么做:
>>>r=requests.get(https://github.com/timeline.json,stream=True) >>>r.raw <requests.packages.urllib3.response.HTTPResponseobjectat0x101194810> >>>r.raw.read(10) \x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03以上就是python requests响应内容的三种方法 ,希望对大家有所帮助 。更多Python学习指路:Python基础教程
创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!