利用ChainMap进行多字典合并

aa = [{105199: 'https://picx0.jpeg'}, {105187: 'https://picx1.jpeg'}, {105170: 'https:picx2.jpeg'}, {104574: 'https://picx3.jpeg'}]

from collections import ChainMap

chain_dict={}
for i,v in enumerate(aa):
    try:
        chain_dict = {**chain_dict,**{**aa[i],**aa[i+1]}}
    except Exception as e:
        pass
print(chain_dict)

 

posted @ 2018-08-09 16:07  Erick-LONG  阅读(438)  评论(0编辑  收藏  举报