Python 将base64字符串还原成图片保存&&图片转base64
base64转图片
import base64 def base64_to_img(bstr, file_path): imgdata = base64.b64decode(bstr) file = open(file_path, 'wb') file.write(imgdata) file.close()
图片转base64
import base64 f = open(img_path, 'rb') img = base64.b64encode(f.read())