利用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)
上一篇:解决IE的背景颜色透明子元素不透明问题


下一篇:(Hibernate进阶)Hibernate映射——一对一单向关联映射(五)