我有一个python脚本,可以生成固定宽度的文本,如下所示:
Hour|Total yyyyyyy|xxxxxx xxxxxxx|Total Inconsistencies|xxxxxxx Inconsistencies
----------------|-------------|---------------|---------------------|-----------------------
2018-12-17_15:00 1893 1 273 (14.42%) 0 ( 0.00%)
2018-12-17_14:00 1844 3 282 (15.29%) 0 ( 0.00%)
2018-12-17_13:00 1850 4 261 (14.11%) 0 ( 0.00%)
2018-12-17_12:00 1760 3 235 (13.35%) 0 ( 0.00%)
2018-12-17_11:00 1771 3 336 (18.97%) 0 ( 0.00%)
2018-12-17_10:00 1770 2 180 (10.17%) 0 ( 0.00%)
2018-12-17_09:00 1685 0 98 ( 5.82%) 0 ( 0.00%)
2018-12-17_08:00 1737 0 109 ( 6.28%) 0 ( 0.00%)
2018-12-17_07:00 1626 0 153 ( 9.41%) 0 ( 0.00%)
2018-12-17_06:00 1724 0 290 (16.82%) 0 ( 0.00%)
2018-12-17_05:00 1782 0 141 ( 7.91%) 0 ( 0.00%)
2018-12-17_04:00 1650 0 76 ( 4.61%) 0 ( 0.00%)
我想以电子邮件的形式发送,以便文本在电子邮件中固定显示。我该怎么办?
答案 0 :(得分:0)
查看您获得的内容类型。如果内容类型为“ Content-Type:文本/纯文本;”那么您会正确看到它。我敢打赌,它是“ Content-Type:text / html”。如果您希望HTML完全按照文本的外观显示,请使用<pre>
和</pre>
。
content = "<pre>" + content + "</pre>"
我可能认为更直接的方法是发送正确的标头:
toClause + "MIME-Version: 1.0\nContent-Type: text/plain\n\n" + content