import os,base64
with open("1.jpg","rb") as f:#转为二进制格式
base64_data = base64.b64encode(f.read())#使用base64进行加密
file=open('1.txt','wb')#写成文本格式
file.write(base64_data)
file.close()
with open("1.txt","r") as f:
imgdata = base64.b64decode(f.read())
file = open('2.jpg','wb')
file.write(imgdata)
file.close()
python 图片base64互转
最新推荐文章于 2024-07-12 19:06:42 发布