When Python is installed, the default encoding is ASCII,
When non-ASCII encoding occurs in a program, Python processing often reports such errors as ' ASCII ' codec can ' t encode characters
Python has no way of handling non-ASCII encodings,
You will need to set the default encoding for Python at this point, which is generally set to UTF8 encoding format.
View Python's default encoding
Print sys.getdefaultencoding ()
Workaround one (passed validation, incidentally also solves the problem of my previous character before the addition of U)
Under the Python installation directory, enter \python27\lib\site-packages
Create a new sitecustomize.py file, set Python's default encoding to UTF8
# Encoding=utf8 Import sys reload (SYS)
Workaround Two
In the py file to be run, add
Import sys Reload (SYS) sys.setdefaultencoding ('UTF8')
Python coding error problem ' ASCII ' codec can ' t encode characters solution