Py中enumerate方法【转载】
生活随笔
收集整理的這篇文章主要介紹了
Py中enumerate方法【转载】
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
轉(zhuǎn)自:http://www.runoob.com/python/python-func-enumerate.html
enumerate(sequence, [start=0])- sequence -- 一個(gè)序列、迭代器或其他支持迭代對(duì)象。
- start -- 下標(biāo)起始位置。
for循環(huán)使用enumerate:
>>>seq = ['one', 'two', 'three'] >>> for i, element in enumerate(seq): ... print i, element ... 0 one 1 two 2 three//在for循環(huán)中會(huì)返回下標(biāo)和對(duì)應(yīng)的元素。
轉(zhuǎn)載于:https://www.cnblogs.com/BlueBlueSea/p/10613474.html
總結(jié)
以上是生活随笔為你收集整理的Py中enumerate方法【转载】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: idea Empty git --ver
- 下一篇: django(七)之数据库表的单表-增删