Python enumerate函数
enumerate——译为枚举
enumerate()函数——Python 2.3. 以上版本可用,2.6 添加 start 参数
作用:遍历可迭代对象(如列表,元组等),同时获得相应的索引及其元素,一般用在for循环当中
语法:
enumerate(sequence, [start=0])
sequence——可迭代对象
start——起始索引(可要可不要)【表示起始索引从start开始】
返回值:枚举对象
lst=[1,2,3,4,5,6,7]
print(type(enumerat
原创
2021-12-30 13:34:04 ·
1036 阅读 ·
0 评论