Reading/writing files

lost lost at soul.net
Mon Apr 14 13:32:02 EDT 2003


Hi there,
I'm a bit lost in terms of reading and writing files.
I've been reading the python docs that came with my distibution, and they
aren't too clear.
I need something like this

for line in a file
	print line
print done

and for writing, I've tried doing file.write(blah) (blah is a list), but
it wont write.
I need to write lists into a file, but i cant.  are there other methods
for printing to a file, other than file.write?
Also, do i need to take into account the \n at the end of a line?
for example, if I have
hello:there
and
hello:there\n
how could i ignore the \n?

cheers!
	




More information about the Python-list mailing list