时间:2021-07-01 10:21:17 帮助过:329人阅读
相关推荐:《python视频》

在Python的for循环里,循环遍历可以写成:
for item in list:
print item它可以遍历列表中的所有元素,但是有什么方法可以知道到目前为止我循环了多少次?
想到的替代方案是:
count=0for item in list:
print item
count +=1
if count % 10 == 0:
print 'did ten'或:
for count in range(0,len(list)):
print list[count]
if count % 10 == 0:
print 'did ten'以上就是Python中记录循环次数的方法的详细内容,更多请关注Gxl网其它相关文章!