在 Python 中怎么同时循环索引和元素

在 Python 中如何同时循环索引和元素

解决办法是使用 enumerate() 函数,例: foo = 'abc' for i, ch in enumerate(foo): printf ch, '(%d)' % i