python 函数-enumerate的用法
2014-12-26 15:11
477 查看
在python中enumerate的用法多用于在for循环中得到计数,本文即以实例形式向大家展现python中enumerate的用法。具体如下:
enumerate参数为可遍历的变量,如 字符串,列表等; 返回值为enumerate类。
示例代码如下所示:
输出为:
enumerate参数为可遍历的变量,如 字符串,列表等; 返回值为enumerate类。
示例代码如下所示:
import string s = string.ascii_lowercase e = enumerate(s) print s print list(e)
输出为:
abcdefghij [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e'), (5, 'f'), (6, 'g'), (7, 'h'), (8, 'i'), (9, 'j')]
相关文章推荐
- python中的enumerate()函数用法
- Python---高级函数map, filter, zip, enumerate等的用法
- Python中enumerate()函数的用法
- Python学习——enumerate()函数的用法
- python enumerate 函数用法
- python enumerate()函数 用法
- Python print函数用法,print 格式化输出
- python 特殊函数的用法
- Python Print函数用法
- Python Print函数用法
- Python3.2 --- Print函数用法
- python map函数用法
- python的一些函数用法记录
- 详细记录python的range()函数用法
- python中List的sort方法(或者sorted内建函数)的用法
- 详细记录python的range()函数用法
- Python中zip函数用法
- Python - 函数中**参数的用法
- python enumerate 用法
- Python Print函数用法