"\n" in ASCII-file

Karl Scalet news at yebu.de
Fri Jul 18 08:28:05 EDT 2003


Martin P schrieb:
> Hello,
> 
> for a short exercise-program I have to read the lines in an ASCII-file.
> 
> But every line has a new-line-feed ("\n") at the end of the line. (The
> ASCII-file was made with Windows Notepad).
> Is this only because I used Windows (and Notepad)?
> 
> And... is there any special method to read lines from a file without "\n"?
> 
> Bye,
> Martin
> 
> 

beside the issue about large or not-so-large files, there
is another difference between Gerhard's line.rstrip() and
my splitlines() method:
entire_file.splitlines() preserves trailing whitespace characters
while line.rstrip() doesn't. Just for the rare case it matters :-)

Karl





More information about the Python-list mailing list