Re: 3 number and dot..
On Oct 31, 9:58 pm, Abandoned <[EMAIL PROTECTED]> wrote:
> Hi..
> I want to do this:
> for examle:
> 12332321 ==> 12.332.321
>
> How can i do?
If you want do define your own function this will work, no matter how
long the number is, or what separator you choose:
def conv(s, sep='.'):
start=len(s)%3
last=start
result=s[0:start]
for i in range(start+1,len(s)):
if (i-start)%3==0:
if last==0:
result+=s[last:i]
else:
result+=sep+(s[last:i])
last=i
if last==len(s) or last==0:
result+=s[last:len(s)]
else:
result+=sep+s[last:len(s)]
return result
print conv('123456789000')
print conv('1')
print conv('123')
print conv('1234')
>>>
1.234.567.890.000.000
1
123
1.234
--
http://mail.python.org/mailman/listinfo/python-list
Re: 3 number and dot..
On Oct 31, 9:58 pm, Abandoned <[EMAIL PROTECTED]> wrote:
> Hi..
> I want to do this:
> for examle:
> 12332321 ==> 12.332.321
>
> How can i do?
Hi,
If you want to define your own function, no matter what the length of
the number is or what separator you want to choose, this will work:
def conv(s, sep='.'):
start=len(s)%3
last=start
result=s[0:start]
for i in range(start+1,len(s)):
if (i-start)%3==0:
if last==0:
result+=s[last:i]
else:
result+=sep+(s[last:i])
last=i
if last==len(s) or last==0:
result+=s[last:len(s)]
else:
result+=sep+s[last:len(s)]
return result
print conv('123456789000')
print conv('1')
print conv('123')
print conv('1234')
>>>
1.234.567.890.000.000
1
123
1.234
--
http://mail.python.org/mailman/listinfo/python-list
Gray Hat Python: Python Programming for Hackers Soft copy
Hi i`m looking for a place to get a soft copy of 'Gray Hat Python: Python Programming for Hackers' may be a pdf or chm format. Thank you -- http://mail.python.org/mailman/listinfo/python-list
Running Invisible console Application
Hi, i have a console application that i want to ran (invisible) as a daemon, how can i do that? Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Creating an Instance Messenger type of application
Hello,Has anyone created an Instance Messenger in Python before, i mean a simple or Complex GUI based instance messenger? I thought about something like, the client also act as server, has it`s own listening port, but how can i handle uer auth? and adding visual effects to it. Please i am not trying to design another Yahoo IM/Skype but just for learning and also want to create real live application using the socket module. -- http://mail.python.org/mailman/listinfo/python-list
