81

python中的enumerate()函数的用法-pengwei59的博客-51CTO博客

 6 years ago
source link: http://blog.51cto.com/13543767/2065895
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
enumerate()函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在for循环当中,可以接手一到两个参数。ex:seq=['one','three','four']循环列表时:普通循环:为foriinseq:print(i)效果为:onethreefour可以看到只是输出列表元素,不带下标的

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK