源码举例:

 1 def enumerate_fn():
 2     '''
 3     enumerate函数:获取每个元素的索引和值
 4     :return:打印每个元素的索引和值
 5     '''
 6     list = ['Mike', 'male', '24']
 7     for index, value in enumerate(list):
 8         print("索引:" + str(index), ", 值:" + value)
 9 
10 
11 enumerate_fn()

运行结果:

索引:0 , 值:Mike
索引:1 , 值:male
索引:2 , 值:24

  

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-12-19
  • 2022-02-11
  • 2022-01-28
相关资源
相似解决方案