python怎么给list加序号?

图片[1]-python怎么给list加序号?-uusu优素-乐高,模型,3d打印,编程

python中给列表加序号的步骤:

1、给出一个列表,定义为ls3

2、用enumerate()函数给列表加序号

3、用for遍历输出加序号后的列表

ls3=['a','b','c','d','e','f']
d=enumerate(ls3)
foriind:
print(i)

运行结果:

原文来自:https://www.py.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享