Asked By – RailsSon
I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.
How can I do this?
Now we will see solution for issue: Currency formatting in Python
See the locale module.
This does currency (and date) formatting.
>>> import locale >>> locale.setlocale( locale.LC_ALL, '' ) 'English_United States.1252' >>> locale.currency( 188518982.18 ) '$188518982.18' >>> locale.currency( 188518982.18, grouping=True ) '$188,518,982.18'
This question is answered By – S.Lott
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0