admin管理员组文章数量:1435859
I was using this code on python previously
with open(f"image.jpg", "wb") as fh:
fh.write(response.content)
and it was working fine, but now I changed lib for requests and the current script doesn't work
That is the new response.text example
while old response.text looks like:
tried this code to decode unicode:
with open(f"image.jpg", "wb") as fh:
fh.write(response.text.encode().decode('unicode_escape').encode())
but the image is not correct, it does not display.
also tried:
ee = base64.encodebytes(rim.content[1:-1].decode('unicode_escape').replace('\\n','').replace('\n','').replace('\\r','').replace('\r','').encode())
and as result got:
I did consider replacing all slashes and \n but still the result string is invalid. I believe there are some decode errors or my mistakes.
I use the same headers for content type and encoding in the request, so please, if it's possible, suggest solutions not related to the request itself.
本文标签: pythonhow to convert response to image with decodingStack Overflow
版权声明:本文标题:python - how to convert response to image with decoding? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745672210a2669638.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论