语法:
enumerate(sequence,[start=0])
test = [i for i in range(9)]
for i in test:
print(i)
for i,j in enumerate(test):
print(i,":",j)
>>>
0
1
2
3
4
5
6
7
8
0 : 0
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5
6 : 6
7 : 7
8 : 8
语法:
enumerate(sequence,[start=0])
test = [i for i in range(9)]
for i in test:
print(i)
for i,j in enumerate(test):
print(i,":",j)
>>>
0
1
2
3
4
5
6
7
8
0 : 0
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5
6 : 6
7 : 7
8 : 8
转载于:https://www.cnblogs.com/zenan/p/9082823.html