@@ -197,14 +197,20 @@ automatically added to the end. ``'r+'`` opens the file for both reading and
197
197
writing. The *mode * argument is optional; ``'r' `` will be assumed if it's
198
198
omitted.
199
199
200
- On Windows and the Macintosh, ``'b' `` appended to the mode opens the file in
201
- binary mode, so there are also modes like ``'rb' ``, ``'wb' ``, and ``'r+b' ``.
202
- Windows makes a distinction between text and binary files; the end-of-line
203
- characters in text files are automatically altered slightly when data is read or
204
- written. This behind-the-scenes modification to file data is fine for ASCII
205
- text files, but it'll corrupt binary data like that in :file: `JPEG ` or
206
- :file: `EXE ` files. Be very careful to use binary mode when reading and writing
207
- such files.
200
+ ``'b' `` appended to the mode opens the file in binary mode, so there are
201
+ also modes like ``'rb' ``, ``'wb' ``, and ``'r+b' ``. Python distinguishes
202
+ between text and binary files. Binary files are read and written without
203
+ any data transformation. In text mode, platform-specific newline
204
+ representations are automatically converted to newlines when read and
205
+ newline characters are automatically converted to the proper
206
+ platform-specific representation when written. This makes writing portable
207
+ code which reads or writes text files easier. In addition, when reading
208
+ from or writing to text files, the data are automatically decoded or
209
+ encoding, respectively, using the encoding associated with the file.
210
+
211
+ This behind-the-scenes modification to file data is fine for text files, but
212
+ will corrupt binary data like that in :file: `JPEG ` or :file: `EXE ` files. Be
213
+ very careful to use binary mode when reading and writing such files.
208
214
209
215
210
216
.. _tut-filemethods :
0 commit comments