这里的更新是我的字典的名单:的Python:在列表中合并多个字典与价值观
dict_list=[{'red':3, 'orange':4}, {'blue':1, 'red':2},
{'brown':4, 'orange':7}, {'blue':4, 'pink':10}]
这里是我的desired outcome
[{'red':5, 'orange':11, 'blue':5, 'brown':4, 'pink':10}]
我已经使用和尝试,但得到一个错误信息,更新似乎并不适合。
update_dict={}
for x in dict_list:
for a in x.items():
update_dict+= x[a]
有什么建议吗?谢谢。
请张贴您的代码。谢谢! –
你正在尝试总结'int'和'str',这会出错。确保您的字典格式正确。 – zeantsoi
你真的确定你想要的字符串和数字中的数字,如你想要的结果吗? – thefourtheye