【发布时间】:2012-12-10 22:09:29
【问题描述】:
我正在编写一个函数来处理布尔 AND 搜索中的多个查询。
我有每个查询发生的文档字典= query_dict
我想要query_dict.values()中所有值的交集:
query_dict = {'foo': ['doc_one.txt', 'doc_two.txt', 'doc_three.txt'],
'bar': ['doc_one.txt', 'doc_two.txt'],
'foobar': ['doc_two.txt']}
intersect(query_dict)
>> doc_two.txt
我一直在阅读有关交集的内容,但我发现很难将其应用于字典。
感谢您的帮助!
【问题讨论】:
-
它不是很清楚你到底想做什么......
标签: python dictionary intersection