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

问题描述 投票:1回答:1

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页面上的最佳方法是什么?

谢谢

python python-3.x flask text-formatting
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.