如何将excel文件转换为base64,然后在python中将base64转换回excel?我打算将Base64数据存储在数据库中,并根据需要检索它并将其转换回excel?有什么帮助吗?
发布于 2020-05-20 04:21:21
import base64
def open_target_file(target_path):
with open(target_path,"rb") as excel_file:
return excel_file.read()
def encode_file(excel_file):
return base64.b64encode(excel_file)
def decode_file():
return base64.b64decode(excel_file)
your_excel_path = ""
destiny_path = ""
excel_file = open_target_file()
encoded_excel = encode_file(excel_file)
decoded_excel = decode_file(encoded_excel)
with open(destiny_path, "wb") as decoded_file:
decoded_file.write(decoded_excel)有时候像这样应该管用。
https://stackoverflow.com/questions/61904942
复制相似问题