"\n" in ASCII-file
Karl Scalet
news at yebu.de
Fri Jul 18 06:49:54 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
>
>
If the file isn't very huge, you could try:
file('yourfile').read().splitlines()
gives you a list of lines w/o '\n'.
Karl
More information about the Python-list
mailing list