insert thousands separators

Marcus Bergmann marcus.bergmann at isst.fhg.de
Fri Jun 13 11:23:05 EDT 2003


P at draigBrady.com wrote:
> Marcus Bergmann wrote:
> 
>> Hi,
>>
>> how can I insert thousands separators into an integer or a string, 
>> e.g. 1000000 to 1.000.000?
> 
> 
> import locale
> 
> #this sets locale automatically (according to LC_ALL environment)
> locale.setlocale(locale.LC_ALL,'')

This sets locale to 'C'. Alternatively I can set it to 'de' (german). 
'us' and others are not supported on my system.

> 
> print locale.format("%d",1000000,1)

I still get 1000000 as output.

> 
> Pádraig.
> 

Marcus






More information about the Python-list mailing list