我正在将图像转换为base64字符串,并将其从android设备发送到服务器。现在,我需要将该字符串更改为图像并将其保存在数据库中。
有什么帮助吗?
发布于 2013-04-25 12:06:31
试试这个:
import base64
imgdata = base64.b64decode(imgstring)
filename = 'some_image.jpg' # I assume you have a way of picking unique filenames
with open(filename, 'wb') as f:
f.write(imgdata)
# f gets closed when you exit the with statement
# Now save the value of filename to your databasehttps://stackoverflow.com/questions/16214190
复制相似问题