python发送邮件,文件后缀变成了bin

问题:在用python做自动化测试时,将html测试报告在邮件中添加文件发送的过程中,发现发送成功后,文件的后缀为.bin

解决方法:

加一行代码

msg_att["Content-Disposition"] = 'attachment; filename="' + filename

顺便分享一下fiename的命名

now_time = time.strftime('%Y-%m-%d %H:%M:%S')
filename = 'report'+now_time+'.html'
posted @ 2019-12-22 22:22  何乐而不为  阅读(1414)  评论(0)    收藏  举报