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页面上的最佳方法是什么?
谢谢
<pre>
</pre>
标签解决了这个格式问题。