formattazione cifra con decimali

Jerry Hill malaclypse2 at gmail.com
Tue Jan 9 08:34:44 EST 2007


On 9 Jan 2007 01:43:41 -0800, Nuke <andrea.massa at gmail.com> wrote:
> I need to visualize a number (or a string of that number) using the
> decimal separator.
> i have this number visualized: 50320,12 and i need that the
> visualization of this number is: 50.320,13.
> There is a function that directly convert the number (or the string) ?

I'm not very familiar with locale-aware programming in Python, but
this may get you started:

>>> import locale

>>> locale.setlocale(locale.LC_ALL, 'it')
'Italian_Italy.1252'

>>> locale.format("%0.2f", 50320.12, grouping=True)
'50.320,12'

See http://docs.python.org/lib/module-locale.html for documentation on
the locale module.

-- 
Jerry



More information about the Python-list mailing list