import string[tab] s = string.ascii_lowercase e = enumerate(s) print s print list(e)
enumerate在循环的同时可以访问到当前的索引值
L = ['a','b','c','d'] for (offset,item) in enumerate(L): print item,'appears at offset:',offset