Formatting numbers
Bjorn Pettersen
BPettersen at NAREX.com
Tue May 1 19:28:40 EDT 2001
Not sure what you're asking here... but the straightforward approach would
be something like:
>>> str(12345/100.0)
'123.45'
If what you want is locale formatted numers you would do:
>>> import locale
>>> locale.setlocale(locale.LC_ALL,'')
>>> locale.format('%.2f', 12345.67, 3)
'12,345.67'
hth,
-- bjorn
> -----Original Message-----
> From: Daniel Klein [mailto:DanielK at jBASE.com]
> Sent: Tuesday, May 01, 2001 5:14 PM
> To: python-list at python.org
> Subject: Formatting numbers
>
>
> This is almost embarrasing to have to ask this but I can't
> seem to find this
> information.
>
> Given an integer, 12345, how to format this to 123.45 ?
>
> Thanks,
> Dan Klein
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list