Splitting text into lines
George Trojan - NOAA Federal
george.trojan at noaa.gov
Tue Dec 13 12:39:24 EST 2016
More information about the Python-list mailing list
Tue Dec 13 12:39:24 EST 2016
- Previous message (by thread): Splitting text into lines
- Next message (by thread): Splitting text into lines
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>
> Tell Python to keep the newline chars as seen with
> open(filename, newline="")
> For example:
> >>>
> * open("odd-newlines.txt", "rb").read() *
> b'alpha\nbeta\r\r\ngamma\r\r\ndelta\n'
> >>>
> * open("odd-newlines.txt", "r", newline="").read().replace("\r", *
> "").splitlines()
> ['alpha', 'beta', 'gamma', 'delta']
Thanks Peter. That's what I needed.
George
- Previous message (by thread): Splitting text into lines
- Next message (by thread): Splitting text into lines
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list