python for语句不设置循环次数怎么用?
在Python的for循环里,循环遍历可以写成:
foriteminlist: printitem
它可以在不设置循环次数的情况下遍历列表中的所有元素。
我们可以使用下面的方法统计循环的次数:
count=0 foriteminlist: printitem count+=1 ifcount%10==0: print'didten'
更多Python知识请关注Python自学网
本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.