python 问题解决:UnicodeEncodeError: 'ascii' codec can't encode character u'\uff08'
第一种方案(90%情况下,大部分帖子都是这个)
一般报错到代码都是自己写到代码,代码上添加
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
第二种方案,引用到包出现错误
在python的lib\site-packages文件夹下新建一个sitecustomize.py
cat sitecustomize.py #添加如下内容,设置编码为utf8
#encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
参考:https://www.cnblogs.com/kevingrace/p/5893121.html
第三种方案 进入python终端,执行如下命令
import sys, codecs, locale; print str(sys.stdout.encoding);
是否是utf8(ubuntu系统)
如果不是,
则修改环境变量PYTHONIOENCODING为utf8
执行:export PYTHONIOENCODING=utf-8
python 问题解决:UnicodeEncodeError: 'ascii' codec can't encode character u'\uff08'的更多相关文章
- Python 排错UnicodeEncodeError 'ascii' codec can't encode character 错误解决方法
Python UnicodeEncodeError 'ascii' codec can't encode character 错误解决方法 by:授客 QQ:1033553122 错误描述: py ...
- Python 错误 UnicodeEncodeError: 'ascii' codec can't encode character 的解决方案
一.使用workbook.get_sheet_by_name(name) 获取excel一个工作表时,发生字符集解析的错误. 网上搜集解决方案为添加以下三句: import sys reload(sy ...
- ERROR (UnicodeEncodeError): 'ascii' codec can't encode character u'\uff08' in position 9: ordinal not in range(128)
环境win10+anaconda2 在安装labelme时遇到了这个问题,其实跟labelme没啥关系,主要是python2读取中文路径时报错,因为默认编码是ASCII,不认识中文,看到有一个一次性解 ...
- python报错问题解决:'ascii' codec can't encode character
之前部署了openstack虚拟化环境,有一天在使用nova list查看虚拟机的时候,突然报错!如下: [root@linux-node1 src]# nova listERROR (Unicode ...
- UnicodeEncodeError: 'ascii' codec can't encode character...的解决方法
在python2.7下,因为想从数据库中读出来分类名进行写入到文件,提示 Traceback (most recent call last): File "test.py", li ...
- Windows下pip安装及更新出现“UnicodeEncodeError: 'ascii' codec can't encode character u'\u258c' in position 8: ordinal not in range(128)”问题解决办法
Windows下pip安装及更新出现“UnicodeEncodeError: 'ascii' codec can't encode character u'\u258c' in position 8: ...
- UnicodeEncodeError: 'ascii' codec can't encode character u'\u65e0' in position 1: ordinal not in range(128)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u65e0' in position 1: ordinal not in ran ...
- UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\u8888′ in position 0: ordinal not in range(168)
python保存文件UnicodeEncodeError以及reload(sys)后print失效问题 在将字符串写入文件时,执行f.write(str),后台总是报错:UnicodeEncodeEr ...
- UnicodeEncodeError: 'ascii' codec can't encode character u'\u5728' in position 1
s = "图片picture"print chardet.detect(s) for c in s.decode('utf-8'): print c UnicodeEncodeEr ...
随机推荐
- Greenplum 监控segment是否正常
在greenplum运行过程中,Segement很有可能因为压力大出现不可用的情况, 主备Segement发现了切换,或是主备Segement网络断开,数据不同步了.在 默认情况下,如果GreenPl ...
- P1833 樱花
题目背景 <爱与愁的故事第四弹·plant>第一章. 题目描述 爱与愁大神后院里种了n棵樱花树,每棵都有美学值Ci.爱与愁大神在每天上学前都会来赏花.爱与愁大神可是生物学霸,他懂得如何欣赏 ...
- Ubuntu16.04 安装 CUDA9.2(总结一些新手容易遇到的问题)
系统:Ubuntu16.04 64bit 显卡:Nvidia GEFORCE 940MX 驱动:NVIDIA-Linux-x86_64-396.18.run 软件:cuda_9.2.88_396.26 ...
- c++ 珊格迷宫问题
#demo1 #include<iostream> #include<ctime> #include<cstdlib> #include<queue> ...
- elasticsearch update方法报错: Too many dynamic script compilations within, max: [75/5m]
PUT _cluster/settings { "transient" : { "script.max_compilations ...
- Layui + 微信小程序 + PC端 + GatewayWorker + 移动端即时聊天系统
- [信息收集]Nmap命令详解
0x00[介绍] Nmap,也就是Network Mapper,中文为"网络映射器". Nmap是一款开源的网络探测和安全审核的工具,它的设计目标是快速地扫描大型网络. 它是网络管 ...
- 【原】Python基础-循环语句
x = 1while x <= 10: print(x) x += 1 password = ""while password != "3213554": ...
- Echarts 常用API之action行为
一.Echarts中的action echarts中支持的图表行为,通过dispatchAction触发. 1.highlight 高亮指定的数据图形 dispatchAction({ type: ' ...
- delphi 解决android 9上无法使用http协议
delphi 解决android 9上无法使用http协议 安卓9不让客户端通过非https方式访问服务端数据(不允许发送明文http请求)的问题. 解决方法: 1.选择安卓平台编译一次程序,在项目根 ...