question about string formatting

G gggg.iiiii at gmail.com
Wed Apr 9 13:17:21 EDT 2008


>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'en_US.UTF-8'
>>> locale.format('%.2f', 1021212.12, True)
'1,021,212.12'
>>>

On Wed, Apr 9, 2008 at 1:04 PM, Kelie <kf9150 at gmail.com> wrote:

> Hello,
>
> Is there something in Python built-in function or library that will
> convert a number 1205466.654 to $1,205,466.65? To add the "$" sign and set
> the decimal place is not a problem, but I don't know how to add the
> thousands delimiter.
>
> Thanks,
>
> --
> Kelie
> UliPad <http://code.google.com/p/ulipad/> is my Python editor.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080409/70f6fc23/attachment.html>


More information about the Python-list mailing list