0
如何在词典列表中替换(每个词典具有相同或不同值的相同键)所有词典with same values of keys id and type which occur more than 0ne time with just one new dictionary with type group
? 我可以通过迭代计数存在,并列出与多个存在和替换的所有组合,但有更快的方式吗?如何在词典列表中替换出现一次以上的所有词典,只有一个新词?
[{id:1, type:1, content:'txt'},{id:2, type:1, content:'abc'},{id:1, type:1, content:'yup'},{id:1, type:1, content:'dmg'}]
将成为
[{id:1, type:'group', content:'txt'},{id:2, type:1, content:'abc'}]
你对'content'做了什么? –
那么,显示你得到的是不是工作,或者你觉得是非常糟糕的设计。也许你已经有了最高效的代码,但是没有人看不到它。 – Evert