Since Python 3.7 you can change the encoding of standard streams with reconfigure()
:
sys.stdout.reconfigure(encoding='utf-8')
You can also modify how encoding errors are handled by adding an errors
parameter.
More Related Contents:
- How to make print() output UTF-8 in Python 3.0?
- What is the best way to remove accents (normalize) in a Python unicode string?
- UnicodeDecodeError: ‘charmap’ codec can’t decode byte X in position Y: character maps to
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3 [duplicate]
- How can I convert surrogate pairs to normal string in Python?
- How to correct TypeError: Unicode-objects must be encoded before hashing?
- Normalizing Unicode
- Facebook JSON badly encoded
- How to redirect stdout and stderr to logger in Python
- NameError: global name ‘unicode’ is not defined – in Python 3
- Why doesn’t Python recognize my utf-8 encoded source file?
- Python 3 print() function with Farsi/Arabic characters [duplicate]
- How to make unicode string with python3
- Python 3: How to specify stdin encoding
- Identifier normalization: Why is the micro sign converted into the Greek letter mu?
- Integer File Descriptor “0” in open()
- “subprocess.Popen” – checking for success and errors
- requests.get returns 403 while the same url works in browser
- How to encode Python 3 string using \u escape code?
- What is internal representation of string in Python 3.x
- Set encoding in Python 3 CGI scripts
- How to deal with unicode string in URL in python3?
- Python 3 chokes on CP-1252/ANSI reading
- Print the result obtained from an external window but without opening the window (the selected checkboxes are automatically saved in the database)
- Syntax error on print with Python 3 [duplicate]
- Why do I need ‘b’ to encode a string with Base64?
- How to escape curly-brackets in f-strings? [duplicate]
- Set up Python simpleHTTPserver on Windows [duplicate]
- Pandas ParserError EOF character when reading multiple csv files to HDF5
- What does colon at assignment for list[:] = […] do in Python [duplicate]