python--base64
import base64
import os
# base64,参数为文件路径名
def file_base64(filepath):
if os.path.isfile(filepath):
with open(filepath, 'rb') as file:
file_base64_str = base64.b64encode(file.read())
return file_base64_str
else:
return None
import base64
import os
# base64,参数为文件路径名
def file_base64(filepath):
if os.path.isfile(filepath):
with open(filepath, 'rb') as file:
file_base64_str = base64.b64encode(file.read())
return file_base64_str
else:
return None