Parsing/Splitting Line
Gabriel Genellina
gagsl-py at yahoo.com.ar
Tue Nov 21 01:50:25 EST 2006
At Tuesday 21/11/2006 02:59, acatejr at gmail.com wrote:
>I have a text file and each line is a list of values. The values are
>not delimited, but every four characters is a value. How do I get
>python to split this kind of data? Thanks.
>>> line = "12340001 2 -3"
>>> for j in range(0,len(line),4):
... print line[j:j+4], int(line[j:j+4])
...
1234 1234
0001 1
2 2
-3 -3
>>>
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list