formatting a string with thousands separators

James Mills prologic at shortcircuit.net.au
Sun Sep 7 23:49:41 CEST 2008


Hi,

There is a much easier more consistent way:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, "en_AU.UTF-8")
'en_AU.UTF-8'
>>> locale.format("%0.2f", 5000000, True)
'5,000,000.00'
>>>

cheers
James

On Mon, Sep 8, 2008 at 5:24 AM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> On 9/7/2008 12:22 PM SimonPalmer apparently wrote:
>>
>> anyone recommend a way of formatting floats with comma separators?
>
>
> http://code.activestate.com/recipes/498181/
>
> Alan Isaac
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list