python2.7编码问题

问题:UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f340' in position 1004: illegal multib

指定文件字符集为utf-8

在文件头部加入以下代码:

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

猜你喜欢

转载自www.cnblogs.com/aliceboy/p/9895647.html