UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

报错如下:

 File "C:\Users\Jackson Li\Envs\mukew\lib\site-packages\django\utils\encoding.py", line 80, in force_text
    s = six.text_type(bytes(s), encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

bug分析:

解决UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range

 

如果你不想点开,那就:在models文件加上以下几句:

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

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)_第1张图片

 

你可能感兴趣的:(django,python)