标签:else style 字典 res result app append class items
s=[{‘a‘: 111}, {‘a‘: 222}, {‘b‘: 333}, {‘c‘: 444}, {‘b‘: 555}] d={} for i in s: for k,v in i.items(): if k not in d: d[k]=[v] else: d[k].append(v) print(d) result = [] for k,v in d.items(): result.append({k:v}) print(result)
标签:else style 字典 res result app append class items
原文地址:https://www.cnblogs.com/wenm1128/p/11741175.html