我正在创建自动邮件系统,我必须每天发送过滤后的excel值
我使用Pandas过滤excel值并将其存储在status中,当使用python发送邮件时,出现了如下错误
TypeError: sequence item 1: expected str instance, Series found
代码:
samples = pd.read_excel(excel_file,sheet_name=0)
status=samples.STATUS == "Need to Update"
msg=EmailMessage()
msg['Subject']='Limit Sample Management System'
msg['From']='abcd@gmail.com'
msg['To']='abcd@gmail.com'
msg.set_content("Kindly Go-Through the below mail",status)
mail=smtplib.SMTP("smtp.gmail.com",587)
mail.login('abcd@gmail.com','123')
mail.send_message(msg)
mail.close()
我只需要发送过滤后的值
错误来自此行:
这个错误告诉您
status
是pandas.Series
。msg.set_content
无法处理,必须将序列转换为字符串。例如用
body
是序列中转换为字符串的所有值的串联(如果它们已经是字符串,则可以省略map
函数)。你知道吗相关问题 更多 >
编程相关推荐