Created
December 26, 2013 07:07
-
-
Save tao4yu/8130738 to your computer and use it in GitHub Desktop.
Python2.7的UnicodeEncodeError: ‘ascii’ codec can’t encode异常错误的一种解决方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 加入如下代码片段, python2.7 默认为ascii编码,改为utf-8 | |
import sys | |
default_encoding = 'utf-8' | |
if sys.getdefaultencoding() != default_encoding: | |
reload(sys) | |
sys.setdefaultencoding(default_encoding) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment