为什么对[1]< [1,2]在Python中
我正在尝试将2个Python列表对象与整数进行比较。我了解Python使用词典比较。在这样做的同时,我遇到了这种情况。当我比较[1]&lt时; [1,2]
python返回true。那不是错误吗?
[1] < [1] # returns False
[1, 2] < [1] # returns False as well
I am trying to compare 2 python list objects with integers. I understand that python uses lexicographical comparison. While doing so I came across this scenario. when I compared [1] < [1, 2]
python returned True. Shouldn't that be False?
[1] < [1] # returns False
[1, 2] < [1] # returns False as well
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论