• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python 不同对象比较大小示例探讨

Python 不同对象比较大小示例探讨

作者:whsnow 字体:[增加 减小] 来源:互联网

whsnow 通过本文主要向大家介绍了python简单代码示例,python示例程序,python代码示例,python示例,python爬虫示例等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

万恶的源泉:

Fireboo的疑问(当然 lambda 本身写的就有问题):

>>> filter( lambda x: x > 2, [ 1, [ 1, 2, 3 ], 2, 3 ] ) 
[[1, 2, 3], 3]
</div>

?:

>>> 1 < [ 1 ] 
True 
>>> int < list 
True 
>>> dict < int < list 
True
</div>
>>> int < map 
False
</div>

后来几经周折,和 Fireboo 讨论了下,是

1.不同对象比较(除了 number 之外),是按照 type names 比较,

2.当相同类型对象不支持适当比较的时候,采用 address 比较

3.list 与 list, tuple 与 tuple 采用字典序比较

>>> x = 1 
>>> y = [ 1 ] 
>>> type( x ) 
<type 'int'> 
>>> type( y ) 
<type 'list'> 
>>> x < y 
True
</div>
>>> type( int ) 
<type 'type'> 
>>> type( list ) 
<type 'type'> 
>>> id( int ) 
505552912 
>>> id( list ) 
505555336 
>>> int < list 
True
</div>
>>> type( map ) 
<type 'builtin_function_or_method'> 
>>> type( list ) 
<type 'type'> 
>>> map < list 
True
</div> </div>

您可能想查找下面的文章:

  • Python编程生成随机用户名及密码的方法示例
  • Python判断变量是否为Json格式的字符串示例
  • python实现逻辑回归的方法示例
  • python分割列表(list)的方法示例
  • Python编程生成随机用户名及密码的方法示例
  • Python判断变量是否为Json格式的字符串示例
  • python实现逻辑回归的方法示例
  • Python实现对字符串的加密解密方法示例
  • Python列表切片用法示例
  • python利用拉链法实现字典方法示例

相关文章

  • 深入学习python的yield和generator
  • python常见数制转换实例分析
  • python检测lvs real server状态
  • python 实现归并排序算法
  • python获取一组汉字拼音首字母的方法
  • Python操作列表的常用方法分享
  • python3中dict(字典)的使用方法示例
  • Python查询阿里巴巴关键字排名的方法
  • python实现bitmap数据结构详解
  • python函数返回多个值的示例方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python3控制路由器——使用requests重启极路由.py
    • 使用python统计文件行数示例分享
    • Python爬虫代理IP池实现方法
    • 使用优化器来提升Python程序的执行效率的教程
    • Python显示进度条的方法
    • Python selenium文件上传方法汇总
    • Python中for循环和while循环的基本使用方法
    • tensorboard实现同时显示训练曲线和测试曲线
    • python变量不能以数字打头详解
    • 使用Python设置tmpfs来加速项目的教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有