我有两个清单:
yy = ['Inside the area', 'Inside the area', 'Inside the area', 'Inside the area', 'Inside the area', 'Inside the area', 'Outside the area']
lat_ = [77.2167, 77.25, 77.2167, 77.2167, 77.2, 77.2167, 77.2]
我使用此处一些帖子中给出的解决方案将它们组合起来:
new_dict = {k: v for k, v in zip(yy, lat_)}
print new_dict
但我的输出是{'Inside the area': 77.2167, 'Outside the area': 77.2}
发生这种情况是因为大多数键都是相同的。我这样做是因为我想映射这两个列表,以便获取哪些 lat 值落在内部或外部,然后仅保留落在内部的值。