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 >>>
原文:http://www.cnblogs.com/ezway/p/6357067.html