getting rid of EOL character ?

stef s.mientki at id.umcn.nl
Fri Apr 27 09:10:11 EDT 2007


hello,

In the previous language I used,
when reading a line by readline, the EOL character was removed.

Now I'm reading a text-file with CR+LF at the end of each line,
    Datafile = open(filename,'r') 
    line = Datafile.readline()

now this gives an extra empty line
    print line

and what I expect that should be correct, remove CR+LF,
gives me one character too much removed
    print line[,-2]

while this gives what I need ???
    print line[,-1]

Is it correct that the 2 characters CR+LF are converted to 1 character ?
Is there a more automatic way to remove the EOL from the string ?

thanks,
Stef Mientki



More information about the Python-list mailing list