Python equivalent of Ruby's each
This question already has an answer here:
就像是:
for i, v in enumerate(a):
print "{} : {}".format(i, v)
That'd be enumerate.
a=['a','b','c']
for i,v in enumerate(a):
print "%i : %s" % (i, v)
Prints
0 : a
1 : b
2 : c
链接地址: http://www.djcxy.com/p/24012.html
上一篇: 与柜台
下一篇: 相当于Ruby的Python