Skip to content

Instantly share code, notes, and snippets.

@tao4yu
Created December 26, 2013 07:07
Show Gist options
  • Save tao4yu/8130738 to your computer and use it in GitHub Desktop.
Save tao4yu/8130738 to your computer and use it in GitHub Desktop.
Python2.7的UnicodeEncodeError: ‘ascii’ codec can’t encode异常错误的一种解决方法
# 加入如下代码片段, 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