问题
How can I avoid using nested tuple unpacking when enumerating a list of tuples like this?
for i, (x, y) in enumerate(zip("1234", "ABCD")):
# do stuff
回答1:
Use itertools.count to avoid nested tuple unpacking:
from itertools import count
for i, x, y in zip(count(), "1234", "ABCD"):
# do stuff
来源:https://stackoverflow.com/questions/11968729/how-can-i-avoid-nested-tuple-unpacking-when-enumerating-zipped-lists