最佳答案
我有一个纬度和一个经度的列表,需要在经纬度对上迭代。
最好是:
A. 假设列表的长度相等:
for i in range(len(Latitudes)):
Lat,Long=(Latitudes[i],Longitudes[i])
B. Or:
for Lat,Long in [(x,y) for x in Latitudes for y in Longitudes]:
(Note that B is incorrect. This gives me all the pairs, equivalent to itertools.product()
)
Any thoughts on the relative merits of each, or which is more pythonic?