filename = "test.html"
f = file(filename)
attachment = MIMEText(f.read(),'html')
msg.attach(attachment)
虽然按照上面的方法,得到Name Error: name 'file' not defined
。请帮助解决此错误。熊猫DF作为电子邮件正文
filename = "test.html"
f = file(filename)
attachment = MIMEText(f.read(),'html')
msg.attach(attachment)
虽然按照上面的方法,得到Name Error: name 'file' not defined
。请帮助解决此错误。熊猫DF作为电子邮件正文
由于没有功能file()
,您必须稍微更改它,该错误消息明确指出。
filename = "text.txt"
with open(filename,'r') as file:
attachment = MIMEText(file.read())
您也许想打开这个文件? :
filename = "test.html"
f = open(filename 'r')
attachment = MIMEText(f.read(),'html')
msg.attach(attachment)
不,实际上我试图复制一个熊猫DF给电子邮件body..but得到它不正确..我的意思是空单元的显示与'南'..如何摆脱这一点? –
这是一个不同的问题,你可以发布你的代码和文件内容。如果我恢复你想要1)打开一个'htlm' 2)把内容放入熊猫数据框3)通过电子邮件发送这些数据?? – Dadep
你用file()期待什么函数? – PRMoureu