On 22/08/2012 09:20, Hans Mulder wrote:
[snip]

Alternatively, if you want to remove only the line separator,
you could do:

         if line.endswith(linesep):
             line = line[:-len(linesep)]

The 'if' command is only necessary for the last line, which may or
may not end in a linesep.  All earlier lines are guaranteed to end
with a linesep.

Even better is:

    line = line.rstrip(linesep)

The line separator is '\n'.

Strictly speaking, the line separator varies according to platform
(Windows, *nix, etc), but it's translated to '\n' on reading from a
file which has been opened in text mode (the default).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to