base64 保存为图片

imgData = base64.b64decode("xxxStr")
# 此处代表从URL或其它地方获取到的图片数据
# 特别要注意必需删除图片base64前面的data:image/png;base64
with open("{}/img.jpg".format(os.getcwd()), "wb") as imgFile:
	imgFile.write(imgData)
# os.getcwd()获取当前执行程序路径,用于拼接需要保存的图片位置
# wb二进制式写

猜你喜欢

转载自blog.csdn.net/u012700515/article/details/112253847