原地址:http://www.newsmth.net/nForum/#!article/Python/95860

最近用到enumerate()函数,于是查了相关的资料 
  
        其中的一篇是这样的:一般情况下,如果要对一个列表或者数组既要遍历索引又要遍历元素时,可以用enumerate 
比如: 
for index,value in enumerate(list): 
      print index,value 
当然也可以 
for i in range(0,len(list)): 
      print i,list[i] 
相比较而言,前者更简练
_

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2022-12-23
  • 2022-01-03
  • 2021-12-08
  • 2022-02-17
相关资源
相似解决方案