【发布时间】:2022-02-03 20:54:18
【问题描述】:
我有一个 python 脚本,它生成一些 HTML 代码以通过电子邮件发送。在脚本中有一个变量(tweet),我想将内容包含在电子邮件中。
这是为电子邮件生成 HTML 的代码:
msg.add_alternative("""\
<!DOCTYPE html>
<html>
<body>
<p>Hi Human,</p>
<p>If you are seeing this, it means that you have received my email. Check out these images!</p>
<p>Best,</p>
<p>Simon</p>
<img src="cid:image1" ><br>
</body>
</html>
""", subtype='html')
我想将变量“tweet”添加到 HTML 代码的正文中,但不知道如何中断 HTML 并插入变量并继续 HTML 以完成。
有人可以帮忙吗?
【问题讨论】: