本博客会不断完善,记录python小功能。
1. 合并两个字典
# in Python 3.5+ >>> x = {‘a‘: 1, ‘b‘: 2} >>> y = {‘b‘: 3, ‘c‘: 4} >>> z = {**x, **y} >>> z {‘c‘: 4, ‘a‘: 1, ‘b‘: 3} # Python 2.x >>> z = dict(x, **y) >>> z {‘a‘: 1, ‘c‘: 4, ‘b‘: 3}
原文地址:https://www.cnblogs.com/carey-he/p/11188738.html
时间: 2024-11-10 14:47:45