解决UnicodeEncodeError: 'ascii' codec can't encode

#coding = GBK

#coding = utf-8

解决UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3问题

转自:http://cooler1217.iteye.com/blog/1465335

异常: 'ascii' codec can't encode characters

字符集的问题,在文件前加两句话:

reload(sys)
sys.setdefaultencoding( "utf-8" )

完美解决,ok

领 当字符串里有 \n、\t、\r时,json.loads()失效,异常,要去掉

你可能感兴趣的:(解决UnicodeEncodeError: 'ascii' codec can't encode)