首页 > 编程语言 > 详细

python enumerate()

时间:2017-01-29 10:40:17      阅读:536      评论:0      收藏:0      [点我收藏+]

enumerate(iterabe[,start])

这个函数是一个迭代器?

可以给一个迭代器后面[]是起始的位置

 如果[]中给了10则会从10开始

 

class enumerate(object):
    """
    enumerate(iterable[, start]) -> iterator for index, value of iterable
    
    Return an enumerate object.  iterable must be another object that supports
    iteration.  The enumerate object yields pairs containing a count (from
    start, which defaults to zero) and a value yielded by the iterable argument.
    enumerate is useful for obtaining an indexed list:
        (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
    """
example:
=============================== >>> a=enumerate(range(5),4) >>> a <enumerate object at 0x000001B4AD750BD0> >>> print(a) <enumerate object at 0x000001B4AD750BD0> >>> for i,j in a: print(i,j) 4 0 5 1 6 2 7 3 8 4 >>>

 

python enumerate()

原文:http://www.cnblogs.com/ezway/p/6357067.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!