【发布时间】:2016-07-15 04:02:45
【问题描述】:
我见过其他将字典中的值加 1 的方法。 当我尝试将值 1 添加到 python 中的字典键值时,我只是不断收到错误。
这是我的代码:
arr = {('1', '20'): [0], ('15', '14'): [0]}
我想给键加 1 ('1', '20')。
这是我的代码:
w = 1
x = 20
arr[(w, x)] += 1
我得到错误代码:
TypeError: 'int' object is not iterable
我根本不知道我做错了什么。非常感谢任何建议。
【问题讨论】:
标签: python dictionary key updates key-value