python2.7运行出现的Warning: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
运行出现如下错误
uncode编码警告:在unicode等价比较中,把两个参数同时转换为unicode编码失败。中断并认为他们不相等。
windows下的字符串str默认编码是ascii,而python编码是utf8
解决方法:添加如下几行代码
import sys reload(sys)
sys.setdefaultencoding('utf8') 或者
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
该解决方法同样适用于如下报错
ascii' codec can't decode byte 0xe6 in position 31: ordinal not in range(128)
python2.7运行出现的Warning: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal的更多相关文章
- python2.7运行报警告:UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal解决办法
1. 程序源代码报错部分: #选择年级if grade == '幼升小': outline.nianji().pop(0).click()elif grade == "一年级": ...
- Python——UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
当字符串比较中有中文时,需要在中文字符串前加 u 转为unicode编码才可以正常比较. str == u"中文"
- 关于在2.7中出现 "UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal"
在中文字符串前面加u. Make sure your code is in UTF-8 (NOT Latin-1) and/or use a coding line as so: #! /usr/bi ...
- python2.7运行selenium webdriver api报错Unable to find a matching set of capabilities
在火狐浏览器33版本,python2.7运行selenium webdriver api报错:SessionNotCreatedException: Message: Unable to find a ...
- WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
在 mkfs.ext4 /dev/sda2 格式化硬盘空间时,可能出现这种错误. had this situation at office where I was told to re-partiti ...
- 运行easy_install安装python相关程序时提示failed to create process
运行easy_install安装python相关程序时提示failed to create process,因为安装了两个python,卸载了的那个目录没删除,删除了另外的python目录后这个问题就 ...
- failed (1113: No mapping for the Unicode character exists in the target multi-byte code page), client: 127.0.0.1...
nginx部署网站后,访问域名,网页显示 500 Internal Server Error ,经查看发现nginx的error.log中有报错: failed (1113: No mapping ...
- Xhprof graphviz Warning: proc_open() [function.proc-open]: CreateProcess failed, error code 解决方法
Xhprof在windows下点击[View Full Callgraph]调用graphviz软件时.警告Warning: proc_open() [function.proc-open]: Cre ...
- WARNING: Re-reading the partition table failed with error 22: Invalid argument
在划分磁盘分区时,遇到错误"WARNING: Re-reading the partition table failed with error 22: Invalid argument&qu ...
随机推荐
- C# FileInfo 类
FileInfo类不像File类,它没有静态方法,仅可用于实例化的对像.FileInfo对像表示在磁盘或网络位置的文件,注意它不是流,为了读写文件,必须创建Stream对像. fileInfo类提供了 ...
- nginx入门学习步骤(linux)
一.nginx下载(nginx-1.9.9) http://nginx.org/download/ 二.解压到指定文件夹 tar -zxvf 解压缩文件 三.设置配置信息 在nignx解压文件夹内执行 ...
- Java - 静态方法不具有多态性
class A1 { public static void f() { System.out.println("A1.f()"); }}class A2 extends A1 { ...
- 该网页无法正常运作 目前无法处理此请求HTTP ERROR 500?
由于php.ini配置文件中错误显示关闭导致. 将下值由Off 变更为 On display_errors = On display_startup_errors = On
- maven引入dubbo包后启动报错
启动后报错内容为: Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exce ...
- [译]The Python Tutorial#2. Using the Python Interpreter
[译]The Python Tutorial#Using the Python Interpreter 2.1 Invoking the Interpreter Python解释器通常安装在目标机器的 ...
- JAVA连接数据库,并写入到txt文件
package Hello; import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;impor ...
- JAVA运行环境配置
win10下,右击我的电脑-->高级系统设置-->高级-->环境变量-->系统变量 1新建 变量名 JAVA_HOME 变量值 C:\Program Files\Jav ...
- PAT Basic 1085
1085 PAT单位排行 每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜.本题就请你实现这个功能. 输入格式: 输入第一行给出一个正整数 N(≤105),即考生人数.随后 N 行, ...
- Android 获取当前应用的版本号+版本号比较
前言:因为项目更新的时候需要一些版本号的信息,后台返回两个string,一个是最低兼容版,一个是最新版.所以拿到数据后要比较一下,所以封装了一个Common包来处理. Step 1 废话不多说, ...