小编And*_*ams的帖子

返回字典Python中所有值的总和

需要帮助制作函数sumcounts(D)其中D是一个以数字作为值的字典,返回所有值的总和.示例输出应如下所示:

>>> sumcounts({"a":2.5, "b":7.5, "c":100})
110.0
>>> sumcounts({ })
0
>>> sumcounts(strcount("a a a b"))
4
Run Code Online (Sandbox Code Playgroud)

python dictionary sum count

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

标签 统计

count ×1

dictionary ×1

python ×1

sum ×1