当前位置:网站首页>enumerate() 函数
enumerate() 函数
2022-07-30 05:38:00 【向大厂出发】
enumerate()(单词意思是枚举的意思)是python中的内置函数,用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。
enumerate()语法
enumerate(sequence, [start=0])参数
- sequence – 一个序列、迭代器、字典或其他支持迭代对象。
- start – 下标起始位置,默认从0开始。
返回值
- 返回 enumerate(枚举对象) 下标号 、成员。
例子:
seasons = ['Spring', 'Summer', 'Fall', 'Winter']
print(list(enumerate(seasons)))
for index, value in enumerate(seasons):
print('索引:', index, '值:%s' % value)
输出:
[(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
索引: 0 值:Spring
索引: 1 值:Summer
索引: 2 值:Fall
索引: 3 值:Winter参考:
边栏推荐
猜你喜欢
随机推荐
JVM之GC 调优工具 Arthas 实战使用(二)
从驱动表和被驱动表来快速理解MySQL中的内连接和外连接
Navicat cannot connect to mysql super detailed processing method
图形镜像对称(示意图)
成绩排序(华中科技大学考研机试题)(DAY 87)
My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
最新版MySQL 8.0 的下载与安装(详细教程)
How is crawler data collected and organized?
解决phpstudy无法启动MySQL服务
倒计数(来源:Google Kickstart2020 Round C Problem A)(DAY 88)
微信小程序开发学习
MySQL 用户授权
机器学习—梯度下降Gradient Descent Optimization—c语言实现
Nacos 原理
Programmers make money and practice, teach you how to do paid courses, self-media, paid articles and paid technical courses to make money
Arrange numbers (DAY90) dfs
Different lower_case_table_names settings for server (‘1‘) and data dictionary (‘0‘) 解决方案
ClickHouse data insert, update and delete operations SQL
Teach you to completely uninstall MySQL
解决没有配置本地nacos但是一直发生localhost8848连接异常的问题









