Chinaunix首页 | 论坛 | 博客
  • 博客访问: 835918
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: Python/Ruby

2012-02-23 11:44:59

  1. 参数为可遍历的变量,如 字符串,列表等;返回值为enumerate类:

  2. import string
  3. s = string.ascii_lowercase
  4. e = enumerate(s)
  5. print s
  6. print list(e)

  7. 输出为:

  8. abcdefghij
  9. [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e'), (5, 'f'), (6, 'g'), (7, 'h'), (8, 'i'), (9, 'j')]
阅读(5452) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~