为什么文本格式不能

2024-04-26 09:33:06 发布

您现在位置:Python中文网/ 问答频道 /正文

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网站上看到时,格式似乎没有任何影响。
将两列文本对齐并粘贴在烧瓶页面上的最佳方法是什么?你知道吗

谢谢


Tags: textnameformatoutputdate格式pricequantity