newbie question

Christoph Lehmann christoph.lehmann at gmx.ch
Thu Sep 4 13:25:20 EDT 2003


hi
I need to read in a textfile, where in each line are two strings:

e.g

aa 1
bb 0
cc 1
aa 0
dd 0


how can I read in each line and put the first string into one variable,
the second into another variable

with just one string per line, I did:

f = open(myfile, 'r')
for filename in f.readlines():
    mylist.append(string.rstrip(filename))                   #remove \n
or \r\n
f.close()

many thanks
-- 
Christoph Lehmann <christoph.lehmann at gmx.ch>






More information about the Python-list mailing list