我创建了一个自动发送电子邮件的脚本,我遇到了一个小问题
附件文件有一些特殊字符,如(ç, á, ã...), 但这是用户的输入,我无法更改
电子邮件传递,但附件文件没有名称和扩展名
你能帮我分析一下代码,看看我能做些什么吗
我知道这和编码有关,但我的技术知识还不足以弄清楚我能做什么
`# attach the body with the msg instance
msg.attach(MIMEText(body, 'plain'))
#get all the attachments
for anexo in anexos:
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(anexo, 'rb').read())
encoders.encode_base64(part)
filename = anexo.split('/')
filename = filename[-1]
print(filename)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % anexo)
msg.attach(part)
`
就像我说的,电子邮件已经发送了,但是附件中没有名字。如果名称中没有特殊字符,则可以正常工作
但问题是我需要发送这些字符
目前没有回答
相关问题 更多 >
编程相关推荐