slicing the end of a string in a list

Peter Otten __peter__ at web.de
Fri Mar 3 02:46:55 EST 2006


John Salerno wrote:

> You can probably tell what I'm doing. Read a list of lines from a file,
> and then I want to slice off the '\n' character from each line.

If you are not concerned about memory consumption there is also

open(filename).read().splitlines()

Peter



More information about the Python-list mailing list