[Exception]’ascii’ codec can’t decode byte 0xe8 in position 2: ordinal not in range(128)

1. The cause of the abnormality

This is an error related to python

 Because by default, Python uses the ascii encoding method, and when Python converts between encoding methods, it will use unicode as the “intermediate encoding”, but the maximum unicode is only as long as 128, so here when trying to encode ascii characters When the string was converted into “intermediate code” unicode, the above error was reported because it exceeded its range.


Two, the solution

Add a sitecustomize.py file in the /usr/lib/python2.7/site-packages/ directory, the content is as follows:

import sys
sys.setdefaultencoding( ' utf-8 ' )

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *