Python中文
首页
教程
问答
标签
搜索
登录
注册
我有两个元组比较。几乎相同的数据。为什么会出现此错误:
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<pre><code>print( ('abc', 1, 2) > ('aaa', 777, 'ssst..') ) print( ('abc', 1, 2) > ('abc', 1, 'ssst..') ) </code></pre> <p>结果:</p> <pre><code>True Traceback (most recent call last): File "//frserv-bu.playtika.local/users$/constantinio/Documents/Python_course/Sedinta3/ex.py", line 33, in <module> print( ('abc', 1, 2) > ('abc', 1, 'ssst..') ) TypeError: '>' not supported between instances of 'int' and 'str' Process finished with exit code 1 </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>第一次比较是将<code>'abc'</code>与<code>'aaa'</code>进行比较,然后它知道结果是什么,不必继续到其他元素</p> <p>在第二次比较中,元组对于前两个元素具有相同的值,因此它必须检查第三个元素,在这一点上,它尝试将<code>2</code>与<code>'ssst..'</code>进行比较,这会导致您看到的错误</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在PyObj中使用respondsToSelector和performSelector
4 回答
如何在pyobj中停止线程
1 回答
如何在pyobj中生成线程
4 回答
如何在pyodbc中为记录集指定游标类型?
8 回答
如何在pyodbc中从用户处获取表名,同时避免SQL注入?
3 回答
如何在pyodbc中使用executemany运行多个SELECT查询
3 回答
如何在pyodbc中同时在n个游标上并行运行n个进程?
3 回答
如何在pyodbc中控制连接池的大小?
2 回答
如何在pyodbc中自动调用fetchall()而不进行异常处理?
3 回答
如何在pyODBC查询中参数化日期戳?
3 回答
如何在pyodbc输出转换器函数中解压sqlserver DATETIME?
5 回答
如何在pyodb中安装所有驱动程序
3 回答
如何在pyodb嵌套循环中调用不同的查询
9 回答
如何在pyomo.environ公司modu装置
3 回答
如何在Pyomoconstraints中建模逻辑或量词
5 回答
如何在Pyomo中为约束使用数组
3 回答
如何在pyomo中使用集和范围集的多级索引?
5 回答
如何在PYOMO中分配伪二进制变量
8 回答
如何在Pyomo中创建OR约束?
8 回答
如何在Pyomo中动态地将变量添加到列表中?
10 回答