Format a number as currency! I can't find any help on this simple problem.

Ben Finney bignose+hates-spam at
Wed Oct 11 05:46:17 CEST 2006

Richard Kessler <richard.kessler at> writes:

> I am relatively new to Python.  Love it, but I find things that I
> can do easily in .NET and cannot find a way to do in Python. I need
> to format a number as currency, for example 12343.56 to $12,343.56.
> In C# all I need to do is decimal x = 12343.56 then
> x.ToString("$###,###.00");

Rather than implement a custom format, Python provides the 'locale'
module to handle locale-specific things like digit-grouping.


 \          "About four years ago, I was -- no, it was yesterday."  -- |
  `\                                                     Steven Wright |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list