Python与序列相关的内建函数
来源:互联网 发布:质量软件 编辑:程序博客网 时间:2024/06/05 04:47
sorted()
sorted(list)使list(tuple)按顺序排序
>>> List=['b','d','c','a']>>> sorted(List)['a', 'b', 'c', 'd']
reversed()
使list(tuple)倒序
>>> reversed(List)<listreverseiterator object at 0x7fc100aee210>>>> for i in reversed(List):... print i... acdb
enumerate()
使list或者tuple输出时前面带索引号
>>> enumerate(List)<enumerate object at 0x7fc100aec870>>>> for i in enumerate(List):... print i... (0, 'b')(1, 'd')(2, 'c')(3, 'a')>>> for i,j in enumerate(List):... print i,j... 0 b1 d2 c3 a
zip()
>>> L=[1,2,4,3]>>> zip(List,L)[('b', 1), ('d', 2), ('c', 4), ('a', 3)]>>> dict(zip(List,L)){'a': 3, 'c': 4, 'b': 1, 'd': 2}
0 0
- Python与序列相关的内建函数
- 与序列相关的几个内建函数
- 迭代序列的三种方法和与序列相关的内建函数
- python 序列类型可用的内建函数
- 与python中的数字相关的内建函数及模块
- python的内建函数与工厂函数
- python中的lambda匿名函数以及针对序列的内建函数map、filter和reduce
- python相关面经-举例说一些python的内建函数
- Python的内建函数str()与repr()
- python的内建函数
- Python 的内建函数
- python的内建函数
- python与内建函数重名
- Python内建函数与对象方法
- python 内建函数详解及相关示例
- Python的输入和raw_input()内建函数等以及相关运算符
- 序列-一些内建函数
- 零基础学python-18.5 函数的内建工具与函数的属性
- Myeclipse 改变代码字体的大小
- vs2012编译器c++存储内存对齐情况详解
- swift基础值网络请求
- 学习android笔记(7):实现微信和新浪微博分享(全)
- Eclipse设置xml用spring编辑器打开的方法
- Python与序列相关的内建函数
- JSON格式数据分析
- 排序函数模板 冒泡法
- 准确率与召回率
- 类的加载
- Spring 基础知识学习
- CXF3.1.6+Spring4.1.9整合
- 常见网络端口及其服务
- JAVA中的static -静态变量-静态方法-静态初始化块