- # 将两个字典合并
- #!/usr/bin/python
- def adddict(dict1,dict2):
- xin = {}
- for key in dict1.keys():
- xin[key] = dict1[key]
- for key in dict2.keys():
- xin[key] = dict2[key]
- return xin
- s1 = {1:222,'c':'d','e':'f'}
- s2 = {2:333,'g':'h','i':'j'}
- print adddict(s1,s2)
- #该片段来自于http://www.codesnippet.cn/detail/2204201512371.html
来源: http://www.codesnippet.cn/detail/2204201512371.html