小编mgr*_*gri的帖子

即使键不同,我如何获得两个词典共有的值?

从两个不同的词典开始:

dict_a = {'a': 1, 'b': 3, 'c': 4, 'd': 4, 'e': 6}
dict_b = {'d': 1, 'e': 6, 'a': 3, 'v': 7}
Run Code Online (Sandbox Code Playgroud)

即使它们有不同的键,我怎样才能得到共同的值?考虑到上面的词典,我希望得到这样的结果:

common = [1, 3, 6]
Run Code Online (Sandbox Code Playgroud)

python dictionary

4
推荐指数
1
解决办法
55
查看次数

标签 统计

dictionary ×1

python ×1