enumerate函数–遍历元素以及下标

enumerate 函数用于遍历序列中的元素以及它们的下标

python文档中是这么说的:

enumerate(sequence, [start=0])
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]), ....

Read More …