语法:enumerate(iterable, start=0)

  • sequence -- 一个序列、迭代器或其他支持迭代对象。
  • start -- 下标起始位置。
  • 返回 enumerate(枚举) 对象。

多用于在for循环中的计数,可以遍历字符串,列表,数组

eg:

 python的枚举函数enumerate的用法

 

python的枚举函数enumerate的用法

 

start -- 下标起始位置

 python的枚举函数enumerate的用法

 

结果对比:

python的枚举函数enumerate的用法

 

相关文章: