Message69862
| Author |
skip.montanaro |
| Recipients |
georg.brandl, skip.montanaro, techtonik |
| Date |
2008年07月17日.01:01:35 |
| SpamBayes Score |
0.0054672346 |
| Marked as misclassified |
No |
| Message-id |
<18558.39404.884345.328631@montanaro-dyndns-org.local> |
| In-reply-to |
<1216148745.81.0.952117625519.issue3359@psf.upfronthosting.co.za> |
| Content |
anatoly> If you open file with 'r' - all line endings will be mapped
anatoly> precisely to '\n' anyways, so it has nothing to do with 'U'
anatoly> mode.
Before 3.0 at least, if you copy a text file from, say, Windows to Mac, and
open it with 'r', you get lines which end in '\r\n'. Here's a simple
example:
>>> open("dos.txt", "rb").read()
'a single line\r\nanother line\r\n'
>>> f = open("dos.txt")
>>> f.next()
'a single line\r\n'
>>> f = open("dos.txt", "r")
>>> f.next()
'a single line\r\n'
>>> f.next()
'another line\r\n'
If, on the other hand, you open it with 'rU', the '\r\n' literal line ending
is converted, even though CRLF is not the canonical Mac line ending:
>>> f = open("dos.txt", "rU")
>>> f.next()
'a single line\n'
>>> f.next()
'another line\n'
Skip |
|