使用内置 enumerate 函数进行遍历:
for index, item in enumerate(sequence):
process(index, item)
实例
>>> sequence =[12,34,34,23,45,76,89]
>>>for i, j in enumerate(sequence):
... print i,j
...
012
134
234
323
445
576
689
使用内置 enumerate 函数进行遍历:
for index, item in enumerate(sequence):
process(index, item)
>>> sequence =[12,34,34,23,45,76,89]
>>>for i, j in enumerate(sequence):
... print i,j
...
012
134
234
323
445
576
689