'ascii' codec can't encode characters in position 34-41: ordinal not in range(128)处理


import sys
reload(sys)


sys.setdefaultencoding('utf-8') 


这个编码设置,运行依然报如上错误。
将代码改为:


print (s.decode('utf-8')).encode('gb2312')


结果没问题了。


所以在使用 print 的时候,要注意环境所需的编码。 


apache依然报如上错误。




export LANG='en_US.UTF-8'


export LC_ALL='en_US.UTF-8'


Consult the documentation for your operating system for the appropriate syntaxand location to put these configuration items; /etc/apache2/envvars is acommon location on Unix platforms. Once you have added these statementsto your environment, restart Apache.
  


1.在ubuntulinux中只需修改/etc/apache2/envvars
在redhat中不存在那个文件那么在/etc/profile添加上相应内容即可。
2.重启apache服务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值