python 邮件更新内容

python email update content

我有一段代码,在 for 循环中发送电子邮件,在 for 循环中为每次迭代更新电子邮件内容。但电子邮件正文没有得到更新。请帮助我。

我试过添加删除消息,但没有成功

for i in range(0,3) :
    data = [[i,i,i,i,i,]]+data
    print(data)
    text = text.format(table=tabulate(data, headers="firstrow", tablefmt="grid"))
    html = html.format(table=tabulate(data, headers="firstrow", tablefmt="html"))
    message = MIMEMultipart(
        "alternative", None, [MIMEText(text), MIMEText(html,'html')])
    #message.attach(MIMEText(html,'html'))i
    sub_time = datetime.datetime.now()+datetime.timedelta(hours=5,minutes=30)
    sub = "Time - "+str(sub_time.hour)+":"+str(sub_time.second)

    message['Subject'] = sub
    message['From'] = me
    message['To'] = you
    server.login(me, password)

    server.sendmail(me, you, message.as_string())

在邮件中,我得到所有 3 次迭代的 0,0,0,0,0+ 数据。

##text = text.format(table=tabulate(data, headers="firstrow", tablefmt="grid"))

text = format(tabulate(data, headers="firstrow", tablefmt="grid"))
##html = html.format(table=tabulate(data, headers="firstrow", tablefmt="html"))

html = format(tabulate(data, headers="firstrow", tablefmt="html"))