insert thousands separators

P at draigBrady.com P at draigBrady.com
Fri Jun 13 17:06:49 CEST 2003


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,'')

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

Pádraig.





More information about the Python-list mailing list