您如何做到这一点,而不保存到磁盘,然后打开'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()发布于 2014-11-30 21:52:16
使用bytes关键字
r = png.Reader(bytes=decoded)发布于 2014-11-30 21:55:15
base53.decodestring()返回二进制数据的字符串,根据此页,png.Reader()可以将字符串作为输入,所以您只需将两者链接在一起即可。
https://stackoverflow.com/questions/27218529
复制相似问题