Skip to content Skip to sidebar Skip to footer

How To Format A Float Number In Python Flask And Jinja?

I've Googled and searched here but can't find an explanation I understand. I've got a value which gets passed into the html template with the value 53.0 which is obtained from a 3

Solution 1:

Thanks to Jake who explained

{{'%0.2f'|format(product_details.UnitPrice|float)}}

Is the correct format to get 2 decimal places.

Solution 2:

Try this:

{{ "£{:,.2f}".format(product_details.UnitPrice) }}

Post a Comment for "How To Format A Float Number In Python Flask And Jinja?"