博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
enumerate用法
阅读量:6952 次
发布时间:2019-06-27

本文共 604 字,大约阅读时间需要 2 分钟。

  

Return an 
enumerate object. sequence must be a sequence, an iterator, or some other object which sup-
ports iteration. The next() method of the iterator returned by 
enumerate() returns a tuple containing
a count (from start which defaults to 0) and the corresponding value obtained from iterating over iter-
able. 
enumerate() is useful for obtaining an indexed series: (0, seq[0]), (1, seq[1]), (2,
seq[2]), .... 
 
For example:
>>> for i, season in 
enumerate([’Spring’, ’Summer’, ’Fall’, ’Winter’]):
...
 print i, season
0 Spring
1 Summer
2 Fall
3 Winter

转载于:https://www.cnblogs.com/yum777/p/6108021.html

你可能感兴趣的文章
[ lucene扩展 ] MoreLikeThis 相似检索
查看>>
如果返回结构体类型变量(named return value optimisation,NRVO)
查看>>
C# 多线程详解 Part.02(UI 线程和子线程的互动、ProgressBar 的异步调用)
查看>>
基于shiro授权过程
查看>>
struts2文件上传
查看>>
JQuery对象和DOM对象的区别与转换
查看>>
wampserver变橙色,apache 服务无法启动!问题解决小记(安装失败亦可参考)
查看>>
使用 Toad 实现 SQL 优化
查看>>
代理模式小记【原创】
查看>>
断开网线后监听服务器配置
查看>>
Date类型转String 与 String转Date类型
查看>>
using关键字
查看>>
Android6.0 新特性详解
查看>>
Graph Convolutional Networks (GCNs) 简介
查看>>
数据库设计中,多对多关系使用使用逗号分割关联讨论
查看>>
介绍一个开源的 C++ 开发框架 openFrameworks 。
查看>>
nodejs 转发websocket (websocket proxy)
查看>>
Audio Codec : MPEG2 AAC -- TNS
查看>>
bash exit
查看>>
测试wlm代码高亮插件
查看>>