python - 如何在字典中找到相同的值

标签 python arrays list dictionary filter

目前我有一个代码可以创建一个字典,其中包含一个键和一个列表作为其值:

e.g. dct = {A: [hello, only], B: [hello, that], C: [hello, same]}

我想比较字典的不同值并识别所有键共享的值。在此示例中,“hello”由所有三个键共享。对 python 来说还是很陌生!太感谢了!

最佳答案

set.intersection(*[set(list) for list in dct.values()])

将为您工作。

关于python - 如何在字典中找到相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53094411/

相关文章:

python - 访问全息 View 中的 Bokeh (图形)参数

php - 不在 CODEIGNITER Mysql 中插入数据库

arrays - 使用 redux 从数组中删除一个元素

java - 当获取 request.getParameter (""时,字符串无法转换为 ArrayList<String> )

python - 为什么这个 3 行程序返回 None 作为输出?

python - 如果卡住了 90 秒,如何从功能中返回?

Python Scrapy 教程 KeyError : 'Spider not found:

python - 使用语言模型进行术语加权

数组和字符串破解编码面试第 6 版解决方案 1.1

arrays - 从 netLogo 中的字符串列表/数组中选择一个随机元素