小编kk_*_*_pl的帖子

在词典词典中总结值

我有这样的事情:

> d1 = {'System tests': {'failed': 5, 'passed': 0, 'total': 5},
       'Func tests': {'failed': 5, 'passed': 0, 'total': 5}}

> d2 = {'System tests': {'failed': 1, 'passed': 1, 'total': 2}, 
        'Func tests': {'failed': 3, 'passed': 2, 'total': 5}}

> d3 = {'System tests': {'failed': 0, 'passed': 0, 'total': 0}, 
        'Func tests': {'failed': 1, 'passed': 0, 'total': 1}}
Run Code Online (Sandbox Code Playgroud)

我想将值'失败',传递和总和加到一个字典中

所以输出应该是这样的:

d4 = {'System tests': {'failed': 6, 'passed': 1, 'total': 7}, 
       'Func tests': {'failed': 9, 'passed': 2, 'total': 11}
Run Code Online (Sandbox Code Playgroud)

做这种事最简单的解决办法是什么?

我可以使用基本库,除了集合. …

python dictionary sum python-3.x

2
推荐指数
1
解决办法
433
查看次数

标签 统计

dictionary ×1

python ×1

python-3.x ×1

sum ×1