标签:rar like bit 使用 explicit any exp hat zip函数
zip((1,2,3),(10,20,30),(100,200,300))
[(1, 10, 100), (2, 20, 200), (3, 30, 300)]
[sum(x) for x in zip((1,2,3),(10,20,30),(100,200,300))]
[111, 222, 333]
To do this with an arbitrarily large set of tuples:
myTuples = [(1,2,3), (10,20,30), (100,200,300)]
[sum(x) for x in zip(*myTuples)]
[111, 222, 333]
sidenote: in python3, note that zip returns a lazy iterable, which you can always explicitly turn into a list like any other kind of iterable: list(zip(…))
标签:rar like bit 使用 explicit any exp hat zip函数
原文地址:https://www.cnblogs.com/LearnFromNow/p/9345421.html