邮件正文中的Python循环

2024-06-03 06:07:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这个html电子邮件正文,并试图建立一个循环来很好地构建一个列表

item = (["<li>{}</li>".format(x) for x in list])
html = """\
<html>
  <body>
    <p>hi:<br>
       <br>
       """ +  str(item) +"""
    </p>
  </body>
</html>
"""

名单如下:

['mango', 'peach', 'banana', 'apple']

电子邮件中的预期结果:

mango

peach

banana

apple

当前结果:

["

'
mango
', '
peach
', '
banana
', '
apple']

"] 

Tags: inbrformatapple列表for电子邮件html