python-UnicodeEncodeError: 'ascii' codec can't encode characters in position

python2和python3都使用的, 比较推荐的做法就是

import sys

import codecs #如果没有codecs包就pip install codecs

sys.stdout=codecs.getwriter('utf-8')(sys.stdout.detach())

python2可以, 但python3不行的做法

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

你可能感兴趣的:(python-UnicodeEncodeError: 'ascii' codec can't encode characters in position)