如何修复 HTML 电子邮件编号列表导致列表超过 99 后出现标签?
How to fix HTML email numbered list causing tabs after list exceeds 99?
我有一个 Python 脚本,它使用 smtplib
、email.mime.multipart
和 email.mime.text
发送带有编号列表的电子邮件。列表超过 99 后,它会在数字后插入制表符并弄乱格式。
到目前为止唯一有效的方法是在每个数字后插入一个换行符以保持格式一致,但它看起来不太好。
for i in range(0:200):
body_row = '<li>First line here <br>Second line here</li>'
body_total += body_row
body_total = "Total List" + "<ol>" + body_total + "</ol>" + "<br>"
输出如下所示:
99. First line here
Second line here
100. First line here
Second line here
101. First line here
Second line here
除了我的换行解决方案之外,有人知道解决此问题的简单方法吗?
您的问题与 Python 编程无关,因为它主要是关于如何在 HTML 中格式化某些内容。
我认为答案是使用 HTML <ol>
ordered list 标签,它会做你想做的事(而且你不必自己明确地给元素编号) .
<ol>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
.
.
.
</ol>
网络浏览器呈现的结果:
另一种方式。我第一次尝试 python,所以请放轻松。
print """<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>"""
for x in range(0, 200):
rowData = """ <tr>
<td> %d</td>
<td>first line<br> second line</td>
</tr>""" % (x)
print rowData
print """ </tbody>
</table>"""
我用 print 看看我的 table 结构怎么样,你可以把这些改成变量。上面的结构将确保您的号码在所有电子邮件客户端上都是正确的,并且列也将在所有客户端上都相同。下面是输出结果的截图。
我有一个 Python 脚本,它使用 smtplib
、email.mime.multipart
和 email.mime.text
发送带有编号列表的电子邮件。列表超过 99 后,它会在数字后插入制表符并弄乱格式。
到目前为止唯一有效的方法是在每个数字后插入一个换行符以保持格式一致,但它看起来不太好。
for i in range(0:200):
body_row = '<li>First line here <br>Second line here</li>'
body_total += body_row
body_total = "Total List" + "<ol>" + body_total + "</ol>" + "<br>"
输出如下所示:
99. First line here
Second line here
100. First line here
Second line here
101. First line here
Second line here
除了我的换行解决方案之外,有人知道解决此问题的简单方法吗?
您的问题与 Python 编程无关,因为它主要是关于如何在 HTML 中格式化某些内容。
我认为答案是使用 HTML <ol>
ordered list 标签,它会做你想做的事(而且你不必自己明确地给元素编号) .
<ol>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
.
.
.
</ol>
网络浏览器呈现的结果:
另一种方式。我第一次尝试 python,所以请放轻松。
print """<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>"""
for x in range(0, 200):
rowData = """ <tr>
<td> %d</td>
<td>first line<br> second line</td>
</tr>""" % (x)
print rowData
print """ </tbody>
</table>"""
我用 print 看看我的 table 结构怎么样,你可以把这些改成变量。上面的结构将确保您的号码在所有电子邮件客户端上都是正确的,并且列也将在所有客户端上都相同。下面是输出结果的截图。