locale doesn' format
Дамјан Георгиевски
gdamjan at gmail.com
Mon Jul 20 20:33:39 EDT 2009
> I want to format values to the german form eg. 1.034,56 but
> locale.format() doesn't work for me.
seems to work here
>>> import decimal, locale
>>> locale.setlocale(locale.LC_ALL, 'mk_MK.UTF-8')
'mk_MK.UTF-8'
>>> locale.localeconv()['grouping']
[3, 3, 0]
>>> locale.localeconv()['thousands_sep']
' '
>>> locale.localeconv()['decimal_point']
','
>>> locale.format('%f', 1034.56,True)
'1 034,560000'
>>> locale.format('%d', 1034.56,True)
'1 034'
ps.
you can copy/paste the above in .txt file and then run/test it with:
python -m doctest -v check.txt
--
дамјан ( http://softver.org.mk/damjan/ )
Begin...the rest is easy.
More information about the Python-list
mailing list