【发布时间】:2021-01-19 00:39:02
【问题描述】:
我正在尝试以二进制格式打开一个 pdf 文件并将其编码为 base64(“utf-8”),但我收到了以下错误消息:
AttributeError: '_io.BufferedReader' 对象没有属性 'b64encode'
我正在使用 Windows 10 和 python 3,代码:
attach_file_name = os.getcwd() + '\doc.pdf'
attach_file = open(attach_file_name, "rb")
attach_file = attach_file.b64encode("utf-8")
【问题讨论】:
标签: python pdf encoding base64