How do you do this without saving to disk and then opening 'out.png' ?
r = requests.get(url)
mine,encoded = r.json()[0]['data'].split(',') #if it is segmentation
decoded = base64.decodestring(encoded)
if mine == 'data:image/png;base64':
#TODO do this from memory
g = open("out.png", "w")
g.write(decoded)
g.close()
r = png.Reader('out.png')
print r.read()
使用bytes
关键字
r = png.Reader(bytes=decoded)
base53.decodestring()
返回二进制数据的字符串,并且根据此页面 png.Reader()
可以将字符串作为输入,因此只需要将两者链接在一起即可。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.