我找到了解决方案。我替换了这一行:
pdf = open(pdf_path, "rb").read().enpre("base64")
这样 :
with open(pdf_path, 'rb') as f: data = f.read()enpred = base64.b64enpre(data)
现在可以了。我可以在set_content中发送编码文件:
attachment.set_content(enpred)
注意: 以上答案适用于Sendgrid v2或更低版本。对于v3及更高版本:
enpred = base64.b64enpre(data).depre()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)