Detailed explanation of the function of reload(sys) in python

When python is installed, the default encoding is ascii. When non-ascii encoding appears in the program, python's processing often reports an error UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128 ), python cannot handle non-ascii encoding, so you need to set the default encoding of python yourself, generally set to utf8 encoding format.
Add the following code to the program: you can set the encoding to utf8

import sys
reload(sys)
sys.setdefaultencoding('utf8')

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324467911&siteId=291194637