圆月山庄资源网 Design By www.vgjia.com
1.描述:
enumerate()函数用于将一个可遍历的数据对象(如列表,元组,字符串)组合为一个索引序列,同时列出数据和数据索引(下标),一般用于for循环当中
2.语法
enumerate(sequence, [start=0])
3.参数:
- sequence:一个序列,迭代器或其他支持迭代对象
- start:可选参数,下标起始位置,默认从索引0开始
4.返回值
返回enumerate(枚举)对象
5.实例
list1 = [10,20,30,40,"maple","yf",60] tup1 = (100,200,300,400,"hao","qazert",600) str1 = "1234qwertjdsa22323" for index1,item1 in enumerate(list1): print("index1 = %d, item1 = %s" %(index1,item1,)) print("------------------------------") for index2, item2 in enumerate(list1,start = 2): print("index2 = %d, item2 = %s" %(index2,item2,)) print("******************************") for index3,item3 in enumerate(tup1): print("index3 = %d, item3 = %s" % (index3, item3,)) print("==============================") for index4,item4 in enumerate(tup1, start = 4): print("index4 = %d, item4 = %s" % (index4, item4,)) print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%") for index5,item5 in enumerate(str1): print("index4 = %d, item4 = %s" % (index5, item5,)) print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$") for index6,item6 in enumerate(str1,start = 6): print("index4 = %d, item4 = %s" % (index6, item6,)) #输出的结果如下: index1 = 0, item1 = 10 index1 = 1, item1 = 20 index1 = 2, item1 = 30 index1 = 3, item1 = 40 index1 = 4, item1 = maple index1 = 5, item1 = yf index1 = 6, item1 = 60 ------------------------------ index2 = 2, item2 = 10 index2 = 3, item2 = 20 index2 = 4, item2 = 30 index2 = 5, item2 = 40 index2 = 6, item2 = maple index2 = 7, item2 = yf index2 = 8, item2 = 60 ****************************** index3 = 0, item3 = 100 index3 = 1, item3 = 200 index3 = 2, item3 = 300 index3 = 3, item3 = 400 index3 = 4, item3 = hao index3 = 5, item3 = qazert index3 = 6, item3 = 600 ============================== index4 = 4, item4 = 100 index4 = 5, item4 = 200 index4 = 6, item4 = 300 index4 = 7, item4 = 400 index4 = 8, item4 = hao index4 = 9, item4 = qazert index4 = 10, item4 = 600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% index4 = 0, item4 = 1 index4 = 1, item4 = 2 index4 = 2, item4 = 3 index4 = 3, item4 = 4 index4 = 4, item4 = q index4 = 5, item4 = w index4 = 6, item4 = e index4 = 7, item4 = r index4 = 8, item4 = t index4 = 9, item4 = j index4 = 10, item4 = d index4 = 11, item4 = s index4 = 12, item4 = a index4 = 13, item4 = 2 index4 = 14, item4 = 2 index4 = 15, item4 = 3 index4 = 16, item4 = 2 index4 = 17, item4 = 3 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ index4 = 6, item4 = 1 index4 = 7, item4 = 2 index4 = 8, item4 = 3 index4 = 9, item4 = 4 index4 = 10, item4 = q index4 = 11, item4 = w index4 = 12, item4 = e index4 = 13, item4 = r index4 = 14, item4 = t index4 = 15, item4 = j index4 = 16, item4 = d index4 = 17, item4 = s index4 = 18, item4 = a index4 = 19, item4 = 2 index4 = 20, item4 = 2 index4 = 21, item4 = 3 index4 = 22, item4 = 2 index4 = 23, item4 = 3
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月02日
2024年11月02日
- 《暗喻幻想》顺风耳作用介绍
- 崔健1985-梦中的倾诉[再版][WAV+CUE]
- 黄子馨《追星Xin的恋人们2》HQ头版限量编号[WAV+CUE]
- 孟庭苇《情人的眼泪》开盘母带[低速原抓WAV+CUE]
- 孙露《谁为我停留HQCD》[低速原抓WAV+CUE][1.1G]
- 孙悦《时光音乐会》纯银CD[低速原抓WAV+CUE][1.1G]
- 任然《渐晚》[FLAC/分轨][72.32MB]
- 英雄联盟新英雄安蓓萨上线了吗 新英雄安蓓萨技能介绍
- 魔兽世界奥杜尔竞速赛什么时候开启 奥杜尔竞速赛开启时间介绍
- 无畏契约CGRS准星代码多少 CGRS准星代码分享一览
- 张靓颖.2012-倾听【少城时代】【WAV+CUE】
- 游鸿明.1999-五月的雪【大宇国际】【WAV+CUE】
- 曹方.2005-遇见我【钛友文化】【WAV+CUE】
- Unity6引擎上线:稳定性提升、CPU性能最高提升4倍
- 人皇Sky今日举行婚礼!电竞传奇步入新篇章