Newbie question: files..

Gerrit Holl gerrit.holl at pobox.com
Fri Oct 22 08:01:27 EDT 1999


Wesley C. wrote:
> > > The code I have is here:
> > >
> > > #!/usr/bin/python
> > >
> > > file = open('testfile.txt', 'r')
> > > for line in file.readlines(): # read file
> > >     s = line[:-1] # get rid of newline
> > >     print s #print string
> > > file.close()

Not good, sometimes the last line doesn't end in a newline.

regards,
Gerrit Holl.




More information about the Python-list mailing list