用base64 对图片文件的编码和解码处理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import base64
def convert(image):
f = open(image)
img_raw_data = f.read()
f.close()
img_b64_string = base64.b64encode(img_raw_data)
convert_img_raw_data = base64.b64decode(img_b64_string)
t = open("example.png", "w+")
t.write(convert_img_raw_data)
t.close()
if __name__ == "__main__":
convert("test.png")
本文网址: https://pylist.com/topic/139.html 转摘请注明来源