python trick合并字典小技巧整理
import os,sys
import copy
from collections import Counter
x = {"a":1,"b":2}
y = {"c":2,"d":4}
# method_1
z = dict(x,**y)
print z
# method_2
z = copy.deepcopy(x)
z.update(y)
print z
原创
2018-12-04 15:04:19 ·
197 阅读 ·
0 评论