文件 编码为Base64字符串
参考
import base64 # 读取文件内容并编码为Base64字符串 file_path = 'pdf_ceshi.docx' with open(file_path, 'rb') as file: file_data = file.read() file_base64_str = base64.b64encode(file_data).decode('utf-8') # 打印Base64字符串(或者可以保存到某个地方) print(file_base64_str)

浙公网安备 33010602011771号