首页 > 编程 > Python > 正文

python的enumerate()函数

2019-11-08 01:10:40
字体:
来源:转载
供稿:网友

enumerate()函数是会返回index(下标)和value(值)的函数 实际上,enumerate()在每次循环中,返回的是一个包含两个元素的定值表(tuple),两个元素分别赋予index和value。

实例

这里写图片描述

文档

"""Docstring:enumerate(iterable[, start]) -> iterator for index, value of iterableReturn an enumerate object. iterable must be another object that supportsiteration. The enumerate object yields pairs containing a count (fromstart, which defaults to zero) and a value yielded by the iterable argument.enumerate is useful for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ...Type: type"""
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表