Answer the question
In order to leave comments, you need to log in
How to change US-ASCII encoding to UTF-8 in Python 3.x?
Good day! When I run the program from the console (Linux), I get the error Unicodeencodeerror ascii codec can't encode characters in position 0-7 . I started looking for the error. It turned out that when running the program from the console, the locale.getpreferredencoding() function gives out: US-ASCII
UTF-8 is needed for normal text decod, but there is no sys.setdefaultencoding('utf-8') function in Python 3.
Question: How to change the encoding?
Answer the question
In order to leave comments, you need to log in
# -*- coding: utf-8 -*-
just insert at the beginning of the program
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question