V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  xss  ›  全部回复第 23 页 / 共 23 页
回复总数  441
1 ... 14  15  16  17  18  19  20  21  22  23  
2016-06-01 13:58:33 +08:00
回复了 petelin 创建的主题 问与答 如何合并两个存放字典的列表?
hash_array = {}
for each_item in a+b :
if each_item['id'] not in hash_array :
hash_array[each_item['id']] = {'total':each_item['total']} #或者是 sum,自己判断吧,这里只说意思
else :
hash_array[each_item['id']]['sum'] = each_item['sum']
1 ... 14  15  16  17  18  19  20  21  22  23  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2818 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 05:58 · PVG 13:58 · LAX 22:58 · JFK 01:58
Developed with CodeLauncher
♥ Do have faith in what you're doing.