Python enumerate用法
来源:互联网 发布:怎么养才能加入淘宝网 编辑:程序博客网 时间:2024/05/17 02:59
在同时需要用到index和value值的时候可以用到enumerate,参数为可遍历的变量,如字符串,列表等,返回enumerate类。
转自:http://www.2cto.com/kf/201212/179579.html
例:
import strings = string.ascii_lowercasee = enumerate(s)print sprint list(e)
输出结果为:
[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e'), (5, 'f'), (6, 'g'), (7, 'h'),
(8, 'i'), (9, 'j'), (10, 'k'), (11, 'l'), (12, 'm'), (13, 'n'), (14, 'o'), (15,
'p'), (16, 'q'), (17, 'r'), (18, 's'), (19, 't'), (20, 'u'), (21, 'v'), (22, 'w
'), (23, 'x'), (24, 'y'), (25, 'z')]
- python --enumerate用法
- python中enumerate用法
- python enumerate 用法
- python enumerate 用法
- Python enumerate用法
- python enumerate 的用法
- python enumerate用法
- python --enumerate用法
- python enumerate 用法
- Python中enumerate用法
- python --enumerate用法
- python --enumerate用法
- python --enumerate用法
- python enumerate用法
- python enumerate 用法
- python enumerate用法总结
- python enumerate 用法小结
- python enumerate用法总结
- CentOS Linux服务器安全设置
- 十一、初学Java多线程:使用Synchronized块同步变量
- Cocos2Dx 内存管理封装
- 五个砝码问题(用三进制)
- Struts2 单文件上传
- Python enumerate用法
- Android中软键盘的显示和隐藏
- Comments Off18 Tools and Source Code Components for Cocos2D iOS Game Development
- ruby 读取yaml文件
- 02-导入版权信息(jsp基本应用)
- Flash Player 问题 | Windows 8
- UVa 558 - Wormholes
- Python 深拷贝与浅拷贝
- 盘点木质和钢制办公家具保养