{"id":1562,"date":"2021-02-14T03:50:28","date_gmt":"2021-02-14T03:50:28","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1562"},"modified":"2021-10-14T03:50:50","modified_gmt":"2021-10-14T03:50:50","slug":"python-merge-dict","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2021\/02\/python-merge-dict\/","title":{"rendered":"python\u5408\u5e76\u5b57\u5178"},"content":{"rendered":"

\u9700\u6c42\uff1a\u5982\u4f55\u5408\u5e76\u4e24\u4e2a\u6216\u8005\u591a\u4e2a\u5b57\u5178\uff1f
\n\u4ee3\u7801<\/p>\n

\n
dictnne1 = {'PC': [1, 2, 3], 'ASE': [4, 5, 6]}\ndictnne2 = {'PUSH': [7, 8, 9], 'STORE': [10, 11, 12]}\ndictnne3 = {'BROWSER': [13, 14], 'GAME': [15, 16]}\n\nnewdict = {**dictnne1, **dictnne2, **dictnne3}\nprint(newdict)<\/code><\/pre>\n<\/div>\n

\u7ed3\u679c<\/p>\n

\n
{'PC': [1, 2, 3], 'ASE': [4, 5, 6], 'PUSH': [7, 8, 9], 'STORE': [10, 11, 12], 'BROWSER': [13, 14], 'GAME': [15, 16]}<\/code><\/pre>\n<\/div>\n

\u4f46\u662f\uff0c\u522b\u9ad8\u5174\u5f97\u592a\u65e9\uff0c\u8fd9\u91cc\u6709\u5751\uff0c<\/p>\n

\n
dictnne1 = {'PC': [1, 2, 3], 'ASE': [4, 5, 6]}\ndictnne2 = {'PC': [7, 8, 9], 'STORE': [10, 11, 12]}\n\nprint({**dictnne1, **dictnne2})<\/code><\/pre>\n<\/div>\n

\u7ed3\u679c\u5982\u4e0b<\/p>\n

\n
{'PC': [7, 8, 9], 'ASE': [4, 5, 6], 'STORE': [10, 11, 12]}<\/code><\/pre>\n<\/div>\n

\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cPC\u8fd9\u4e2a\u952e\u503c\u5bf9\u88ab\u5f3a\u5236\u8986\u76d6\u4e86\uff0c\u4f7f\u7528\u4e4b\u524d\u4e00\u5b9a\u8981\u6ce8\u610f\u4e0b\u3002<\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » python\u5408\u5e76\u5b57\u5178<\/a><\/p>","protected":false},"excerpt":{"rendered":"

\u9700\u6c42\uff1a\u5982\u4f55\u5408\u5e76\u4e24\u4e2a\u6216\u8005\u591a\u4e2a\u5b57\u5178\uff1f \u4ee3\u7801 dictnne1 = {‘PC’: [1, 2, 3], ‘ASE’: [4, 5, 6]} dictnne2 = {‘PUSH’: [7, 8, 9], ‘STORE’: [10, 11, 12]} dictnne3 = {‘BROWSER’: [13, 14], ‘GAME’: [15, 16]} newdict = {**dictnne1, **dictnne2, **dictnne3} print(newdict) \u7ed3\u679c {‘PC’: [1, 2, 3], ‘ASE’: [4, 5, 6], ‘PUSH’: [7, 8, 9], ‘STORE’: [10, 11, 12], ‘BROWSER’: [13, […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[59],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1562"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1562"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1562\/revisions"}],"predecessor-version":[{"id":1563,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1562\/revisions\/1563"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}