Files
06-Note/Python-100-Days/Day01-15/Day11/file4.py
sherlockforrest bf2ed2e31f 更新
2023-06-20 09:22:53 +08:00

24 lines
350 B
Python

"""
读写二进制文件
Version: 0.1
Author: 骆昊
Date: 2018-03-13
"""
import base64
with open('mm.jpg', 'rb') as f:
data = f.read()
# print(type(data))
# print(data)
print('字节数:', len(data))
# 将图片处理成BASE-64编码
print(base64.b64encode(data))
with open('girl.jpg', 'wb') as f:
f.write(data)
print('写入完成!')