我有一个这样的字典列表:
lst = [{'City or Community': 'Augusta', 'State':'GA', 'Parent Company': 'WoW!'},
{'City or Community': 'Augusta', 'State':'GA', 'Parent Company': 'Comcast'}]
迭代列表以查找城市/州组合具有多个结果的实例的最有效方法是什么?你知道吗
这就是我现在要做的:
def search(complete):
#searching through the full list for footprints which overlap by city, county, state, etc
trial = []
for y in complete:
for x in complete:
for subdicts in y:
for otherdicts in x:
if otherdicts['Parent Company'] != subdicts['Parent Company'] and (otherdicts['City or Community'], otherdicts['State']) == (subdicts['City or Community'], subdicts['State']):
以下是defaultdict的一种方法:
试试
collections.Counter()
:相关问题 更多 >
编程相关推荐