小编Abd*_*eem的帖子

比较python中的两个dict以获得类似键的最大值

我有这两个词:

a={"test1":90,  "test2":45,  "test3":67,  "test4":74}
b={"test1":32,  "test2":45,  "test3":82,  "test4":100}
Run Code Online (Sandbox Code Playgroud)

如何提取相同键的最大值以获得新的dict,如下所示:

c={"test1":90,  "test2":45,  "test3":82,  "test4":100}
Run Code Online (Sandbox Code Playgroud)

python dictionary compare

4
推荐指数
2
解决办法
1275
查看次数

标签 统计

compare ×1

dictionary ×1

python ×1