How to convert php number_format() function to python

Viewed 1098

I want to convert php code to python3.

this is my php code

echo "<td class='text-left'>".number_format($amount,2)."</td>";

I want to convert this php into Python. Please help me in that

1 Answers
import locale


def number_format(num, places=0):
    return locale.format_string("%.*f", (places, num), True)

Using:

print(number_format(12345.6789, 2))

Result:

12345.68

More info

Related