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 == "一年级":
outline.nianji().pop(1).click() # 一年级
elif grade == "二年级":
outline.nianji().pop(2).click() # 二年级
elif grade == "三年级":
outline.nianji().pop(3).click() # 三年级
elif grade == "四年级":
outline.nianji().pop(4).click() # 四年级
elif grade == "五年级":
outline.nianji().pop(5).click() # 五年级 2.运行程序时的报错信息:
uncode编码警告:在unicode等价比较中,把两个参数同时转换为unicode编码失败。中断并认为他们不相等。
windows下的字符串str默认编码是ascii,而python编码是utf8
3. 解决办法:
在代码中加入如下:
import sys
reload(sys)
sys.setdefaultencoding('utf8')
python2.7运行报警告:UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal解决办法的更多相关文章
- 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,而pytho ...
- 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 ...
- Mac环境安装非APP STORE中下载的软件,运行报错:“XXX” is damaged and can’t be opened. You should move it to the Trash. 解决办法
出现这个错误的大多数原因都是因为系统设置的问题,因为系统不信任你从其他地方下载的软件安装包,所以运行时就给你阻止了.具体的设置步骤如下: 1. 打开系统偏好设置 (System Preferences ...
- 【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 解决办法
Docker Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke ...
- xcode 运行报错 Command /usr/bin/codesign failed with exit code 1
因为更换了证书,导致在运行时报错 Command /usr/bin/codesign failed with exit code 1,查看了网上各种方法,最后发现以下两个值没有同步更新
- jdk1.8+SpringAOP注解报java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut select错误的不知原因的解决办法[仅供参考]
先说办法:如果Aspectweaver-1.*.*jar这三个包版本比较低, 比如1.5.0这一层次的,可以找版本高一点的包替换低版本的包,问题可以得到解决 jar包的下载地址:https://mvn ...
- 运行报警告UserWarning: Unknown extension is not supported and will be removed warn(msg)
运行python代码,出现如下警告: C:\Users\niko\PycharmProjects\python_new\venv\lib\site-packages\openpyxl\reader\w ...
- spring 以Ant Build方式运行build.xml文件,报warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 的解决办法
Buildfile: F:\experience\spring_pdf\sourcecode\example1\build.xml compile: [javac] F:\experience\spr ...
随机推荐
- redis在Windows下以后台服务一键搭建哨兵(主从复制)模式(单机)
redis在Windows下以后台服务一键搭建哨兵(主从复制)模式(单机) 一.概述 此教程介绍如何在windows系统中单机布置redis哨兵模式(主从复制),同时要以后台服务的模式运行.布置以脚本 ...
- 工作流性能优化(敢问activiti有扩展性?)(1)
工作流待办(首页待办列表),加载缓慢,activiti本机,看了代码又是全部数据加载到内存,然后代码过滤,我为什么又说又呢? 用VisualVM做性能测试: 之前同事给的解决方案: 1.把&quo ...
- hdu-1198 Farm Irrigation---并查集+模拟(附测试数据)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1198 题目大意: 有如上图11种土地块,块中的绿色线条为土地块中修好的水渠,现在一片土地由上述的各种 ...
- 2018.10.26 NOIP2018模拟赛 解题报告
得分: \(0+10+10=20\)(\(T1\)死于假题面,\(T3\)死于细节... ...) \(P.S.\)由于原题是图片,所以我没有上传题目描述,只有数据. \(T1\):颜料大乱斗(点此看 ...
- cf1151 B
题目连接 : https://codeforces.com/contest/1151/problem/B 可能我想法有问题,我怎么感觉B题的思路不直接想出来的,我想了一会才想出来,感觉不难,但可能有更 ...
- TypeScript task
Ctrl+Shift+B 生成 js 文件.
- Scanner和 Random类,控制语句的例题,商品管理(直接赋值)
Scanner类的使用: import java.util.Scanner; class Demo02 { public static void main(String[] args) { //1.导 ...
- Linux下Jenkins与GitHub自动构建NetCore与部署
今天我们来谈谈NetCore在Linux底下的持续集成与部署.NetCore我就不多介绍了,持续集成用的是Jenkins,源代码管理器用的是GitHub.我们就跟着博文往下走吧. 1.Linux环境 ...
- Jquery点击数字切换图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- C# checked运算符
一.C# checked运算符 checked运算符用于对整型算术运算和显式转换启用溢出检查. 默认情况下,表达式产生的值如果超出了目标类型的范围,将会产生两种情况: ?常数表达式将导致编译时错误. ...