本文介绍了如何将两个词典连在一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! dict1 = {... ......} dict2 = {... somethind else ..} dict1 + dict2 '确实有效...... :(,它不像List ...... 任何人都可以告诉我该怎么做? 提前谢谢 解决方案 呃,我只是在学习python,所以可能会有更简单的方法来实现这一点,但是你可以: dict3 = {} 为k,我在dict1.iteritems(): dict3 [k] = i 为k,我在dict2.iteritems(): dict3 [k] = i 认为这应该显然,如果同一个键出现在 dict1和dict2然后dict2'的值将覆盖dict1'。 Iain 我想你想要.. dict1.update(dict2) 将McGugan - http://www.willmcgugan.com "" .join({''*' ':''''',''^'':''。''}。得到(c,0)或chr(97+(ord(c)-84)%26)for " jvyy * jvyyzpthtna ^ pbz")dict1={...something...}dict2={...somethind else ..}dict1 + dict2that''s does works ..:(, it''s not like List...anyone can tell me how to get it?thanks in advance 解决方案Uh, I''m just learning python too, so there may be a much simpler way todo this, but you could:dict3 = {}for k,i in dict1.iteritems():dict3[k] = ifor k,i in dict2.iteritems():dict3[k] = iThink this should work. Obviously, if the same key appears in bothdict1 and dict2 then dict2''s value will overwrite dict1''s.IainI think you want..dict1.update(dict2)Will McGugan-- http://www.willmcgugan.com"".join({''*'':''@'',''^'':''.''}.get(c,0) or chr(97+(ord(c)-84)%26) for c in"jvyy*jvyyzpthtna^pbz") 这篇关于如何将两个词典连在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 02:20