insert thousands separators (solved)
Marcus Bergmann
marcus.bergmann at isst.fhg.de
Tue Jun 17 08:54:30 EDT 2003
Problem is solved. I took the following code (from Bengt Richter):
def commafy(self,val):
sign, val, rest = '-'[:val<0], str(abs(val)), []
while val: val, rest = val[:-3], ([val[-3:]] + rest)
return sign + '.'.join(rest)
Thank to all :-)
Regards,
Marcus
Marcus Bergmann wrote:
> Hi,
>
> how can I insert thousands separators into an integer or a string, e.g.
> 1000000 to 1.000.000?
>
> Thanks and cheers,
> Marcus
More information about the Python-list
mailing list