enumerate()函数
enumerate()函数主要用于记录循环的loop循环的索引,起始值为0。
1 >>>l=[1,2,3] 2 >>>for (i,j) in enumerate(l): 3 print("the %ith element in the list is %d" % (i,j)) 4 运行结果: 5 the 0th element in the list is 1 6 the 1th element in the list is 2 7 the 2th element in the list is 3
good good study,day day up!
浙公网安备 33010602011771号