我想迭代枚举Python中的两个列表.以下代码看起来很丑陋.有没有更好的解决方案?
for id, elements in enumerate(itertools.izip(as, bs)):
a = elements[0]
b = elements[1]
# do something with id, a and b
谢谢.
解决方法:
您可以在for循环期间指定a和b:
for id, (a, b) in enumerate(itertools.izip(as, bs)):
# do something with id, a and b