cross platform use of set locale
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Mar 22 19:21:05 EST 2005
In <mailman.746.1111534956.1799.python-list at python.org>, Timothy Smith
wrote:
> hi there i need to set my locale so that when i output a number it's
> formatted with thousands grouped. the problem i've found is there
> doesn't seem to be very good cross platform support for locales, even
> between unix's it's horrid.
Have you tried this::
import locale
locale
locale.setlocale(LC_ALL, '')
locale.format('%.2f', 1000000, True)
The `True` turns on grouping. Should work cross platform.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list