欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python實(shí)現(xiàn)合并字典的方法

 更新時(shí)間:2015年07月07日 16:07:24   作者:defias  
這篇文章主要介紹了Python實(shí)現(xiàn)合并字典的方法,涉及Python針對(duì)字典的遍歷與合并的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Python實(shí)現(xiàn)合并字典的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

# 將兩個(gè)字典合并
#!/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)

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論