📜  python - 如何从字典中减去值 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:17.687000             🧑  作者: Mango

代码示例1
>>> from collections import Counter
>>> d1 = Counter({'a': 10, 'b': 9, 'c': 8, 'd': 7})
>>> d2 = Counter({'a': 1, 'b': 2, 'c': 3, 'e': 2})
>>> d3 = d1 - d2
>>> print d3
Counter({'a': 9, 'b': 7, 'd': 7, 'c': 5})