Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask Python, Why Text Formatting Doesn't Work

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)  

So, printing it to the console shows that the formatting is good, but when seeing it on the localhost website, the formatting seems to have no effect.
What's the best way to align two columns of text and have it stick on the Flask page?

Thanks

like image 567
Anon Li Avatar asked Aug 17 '26 13:08

Anon Li


1 Answers

<pre> </pre> tags solved this formatting issue.

like image 131
Anon Li Avatar answered Aug 20 '26 04:08

Anon Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!