python的enumerate函数

python的enumerate函数用于循环索引和元素

  例如

  

 foo = 'abc'
 for i , ch in enumerate(foo):
	print ch, '(%d)' % i

输出结果:	
a (0)
b (1)
c (2)

 

posted @ 2013-09-27 11:17  河边的老牛  阅读(474)  评论(0编辑  收藏  举报