码迷,mamicode.com
首页 > 编程语言 > 详细

python:'ascii' codec can't encode character

时间:2017-11-15 00:19:37      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:sci   lte   utf8   默认   import   har   encoding   编码   python   

python默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错,python没办法处理非ascii编码的,

此时需要自己设置python的默认编码,一般设置为utf8的编码格式。

cat myutf8.py #添加如下内容,设置编码为utf8
# encoding=utf8 
import sys

reload(sys) 
sys.setdefaultencoding(‘utf8‘)

python:'ascii' codec can't encode character

标签:sci   lte   utf8   默认   import   har   encoding   编码   python   

原文地址:http://www.cnblogs.com/hixiaowei/p/7835399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!