python 发送邮件,附件中文命名,怎么破

2025-05-15 02:49:44
推荐回答(1个)
回答(1):

# #构造附件
    attachment = MIMEText(open('tmp.xls', 'rb').read(), 'base64', 'utf-8')
    attachment["Content-Type"] = 'application/excel'
    attachment["Content-Disposition"] = 'attachment; filename="{0}.xls"'.format(excel_info.encode('gbk'))