[Tutor] Files and such 2
Prospero
prospero at prosperosisland.co.uk
Fri Oct 1 23:19:18 CEST 2004
Greetings!
Thanks to Danny, I now have a piece of code that will do most of what I want for
one line, as follows:-
x = open("numbers.txt","r")
foo = x.readlines()
print foo
bar = foo[0]
print bar
chunks = bar.split(',')
print chunks[0]
a = chunks[0]
print a
(Then it does some other stuff to what it has now got)
x.close()
However, I need to be able to do this for all lines in the file, going forward
for one process and backward for another. Is there a simple way to count the
lines?
All the best,
Prospero.
More information about the Tutor
mailing list