Message386544
In the document about build-in function open() https://docs.python.org/3/library/functions.html#open, it says that
"encoding is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent (whatever locale.getpreferredencoding() returns), but any text encoding supported by Python can be used. See the codecs module for the list of supported encodings.
"
But as I tried, I found that after I set locale using locale.setlocale(), the default encoding used by open() was changed and thus sometimes led to a UnicodeDecodeError.
So I think that the default encoding used by open() is the second element of whatever locale returned by locale.getlocale(). |
|
Date |
User |
Action |
Args |
2021-02-06 05:16:14 | smallbigcake | set | recipients:
+ smallbigcake, docs@python |
2021-02-06 05:16:14 | smallbigcake | set | messageid: <1612588574.22.0.21834147948.issue43140@roundup.psfhosted.org> |
2021-02-06 05:16:14 | smallbigcake | link | issue43140 messages |
2021-02-06 05:16:13 | smallbigcake | create | |
|