Flask Python,为什么文本格式不起作用

时间:2019-03-21 00:24:10

标签: python python-3.x flask text-formatting

enter image description here

row1 = ["Date: "  + date,  "Price:"     + price]
row2 = ["Name: "  + name,  "Quantity: " + quantity]
row3 = ["Title: " + title, "Owned: "    + owned]
row4 = ["Type: "  + type,  "Value: "    + value]

output_text = output_text + "\n" + \
              ('{:30s} {:20s}'.format(row1[0], row1[1])) + "\n" + \
              ('{:30s} {:20s}'.format(row2[0], row2[1])) + "\n" + \
              ('{:30s} {:20s}'.format(row3[0], row3[1])) + "\n" + \
              ('{:30s} {:20s}'.format(row4[0], row4[1])) + "\n"

print(output_text)  

因此,将其打印到控制台表明格式很好,但是在localhost网站上看​​到它时,格式似乎无效。
对齐两列文本并将其粘贴在Flask页面上的最佳方法是什么?

谢谢

1 个答案:

答案 0 :(得分:0)

<pre> </pre>标签解决了此格式问题。