3 number and dot..

Hrvoje Niksic hniksic at xemacs.org
Wed Oct 31 22:48:21 CET 2007


Abandoned <besturk at gmail.com> writes:

> Hi..
> I want to do this:
> for examle:
> 12332321 ==> 12.332.321
>
> How can i do?

I'm surprised that no one has proposed a regex solution, such as:

>>> import re
>>> re.sub(r'\d{1,3}(?=(?:\d{3})+$)', r'\g<0>.', str(1234567))
'1.234.567'



More information about the Python-list mailing list