码迷,mamicode.com
首页 > 编程语言 > 详细

enumerate用法

时间:2016-11-28 08:30:11      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:tuple   tor   turned   div   用法   print   res   value   bsp   

  

Return an enumerate object. sequence must be a sequence, an iterator, or some other object which sup-
ports iteration. The next() method of the iterator returned by enumerate() returns a tuple containing
a count (from start which defaults to 0) and the corresponding value obtained from iterating over iter-
able. enumerate() is useful for obtaining an indexed series: (0, seq[0]), (1, seq[1]), (2,
seq[2]), .... 
 
For example:
>>> for i, season in enumerate([’Spring’, ’Summer’, ’Fall’, ’Winter’]):
...
 print i, season
0 Spring
1 Summer
2 Fall
3 Winter

enumerate用法

标签:tuple   tor   turned   div   用法   print   res   value   bsp   

原文地址:http://www.cnblogs.com/yum777/p/6108021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!