Answer the question
In order to leave comments, you need to log in
Python 3 + Flask: charmap codec can't encode character?
A remote client has a Flask web server running, and when trying to print unicode to stdout, the following error occurs - it crashes on the 'Ł' character and the like:
File "C:\project\utils\mycode.py", line 260, in myfunk
print("- [%s]" % text)
File "C:\Python\Python36-32\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\xe4' in position 32:
character maps to <undefined>
chcp 65001
set FLASK_DEBUG=1
set FLASK_APP=backend.py
venv\scripts\flask.exe run --port 5000
from pprint import pprint
import sys
print(sys.version)
pprint('\u0141') # char 'Ł'
3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
'Ł'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question