pythn3-enumerate()

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pythn3-enumerate()相关的知识,希望对你有一定的参考价值。

enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。

>>>seq = [‘one‘, ‘two‘, ‘three‘]
>>>for i, element in enumerate(seq):
...    print(i, seq[i])
... 
0 one
1 two
2 three
>>>

以上是关于pythn3-enumerate()的主要内容,如果未能解决你的问题,请参考以下文章