{"id":84819,"date":"2026-07-26T18:42:19","date_gmt":"2026-07-26T10:42:19","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84819.html"},"modified":"2026-07-26T18:42:19","modified_gmt":"2026-07-26T10:42:19","slug":"python%e7%9a%84%e5%ad%97%e5%85%b8%e7%9f%a5%e8%af%86%e7%82%b9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84819.html","title":{"rendered":"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9"},"content":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u5b66\u4e60python\u4e2d\u7684\u5b57\u5178&#xff0c;\u8fd9\u91cc\u7684\u5b57\u5178\u8ddf\u6211\u4eec\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u5b57\u5178\u5176\u5b9e\u662f\u4e00\u4e2a\u610f\u601d\u3002\u4f20\u7edf\u610f\u4e49\u7684\u5b57\u5178\u6709\u4e00\u4e2a\u67e5\u8be2\u754c\u9762&#xff0c;\u8fd9\u5bf9\u5e94\u7684\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u5065&#xff08;key&#xff09;&#xff1b;\u6bcf\u4e2a\u67e5\u8be2\u5bf9\u8c61\u6709\u5bf9\u5e94\u7684\u9875\u7801\u89e3\u6790&#xff0c;\u8fd9\u4e2a\u5bf9\u5e94\u7684\u89e3\u6790\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u503c&#xff08;value&#xff09;\u3002<\/p>\n<p>\u90a3\u4e48&#xff0c;\u4ec0\u4e48\u662f\u5065\u4ec0\u4e48\u662f\u503c&#xff1f;\u5b57\u5178\u53c8\u6709\u4ec0\u4e48\u4f5c\u7528&#xff1f;\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u5b66\u4e60\u2192<\/p>\n<h2>\u4e00\u3001\u5b9a\u4e49<\/h2>\n<p>\u5b57\u5178\u548c\u96c6\u5408\u4e00\u6837&#xff0c;\u90fd\u662f\u65e0\u5e8f\u53ef\u53d8\u5e8f\u5217\u3002\u5b57\u5178\u4e2d\u7684\u5143\u7d20&#xff0c;\u4e24\u4e24\u914d\u5bf9&#xff0c;\u4ee5\u952e\u503c\u5bf9\u5f62\u5f0f\u5b58\u50a8\u3002<\/p>\n<p>&#034;&#034;&#034;\u57fa\u672c\u8bed\u6cd5&#034;&#034;&#034;<br \/>\n{\u5065(key):\u503c(value),\u5065(key):\u503c(value),\u5065(key):\u503c(value),&#8230;&#8230;}<\/p>\n<p>\u5b57\u5178\u4e2d\u7684\u5065\u5fc5\u987b\u662f\u4e0d\u53ef\u53d8\u7c7b\u578b&#xff0c;\u6bd4\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u5143\u7ec4\u7b49&#xff0c;\u4e14\u5b57\u5178\u4e2d\u7684\u5065\u5fc5\u987b\u5177\u5907\u552f\u4e00\u6027&#xff0c;\u4e00\u4e2a\u5b57\u5178\u4e2d\u4e0d\u80fd\u6709\u4e24\u4e2a\u91cd\u590d\u7684\u5065\u5b58\u5728&#xff0c;\u91cd\u590d\u5b9a\u4e49\u4f1a\u5c06\u65e7\u503c\u8986\u76d6\u3002<\/p>\n<p>\u5b57\u5178\u4e2d\u7684\u503c\u6ca1\u6709\u56fa\u5b9a\u9650\u5236&#xff0c;\u53ef\u4ee5\u662f\u4efb\u4f55\u4e00\u79cd\u5e8f\u5217\u7c7b\u578b\u3002<\/p>\n<p>\u5b57\u5178\u6709\u8bb8\u591a\u751f\u6210\u548c\u521b\u5efa\u65b9\u5f0f\u2b07\ufe0f<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u65b9\u5f0f<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>x&#061;{\u952e\u503c\u5bf9}<\/td>\n<td>\u7b80\u5355\u7c97\u66b4&#xff0c;\u76f4\u63a5\u5b57\u9762\u91cf\u521b\u5efa<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>dict()<\/td>\n<td>\u4f7f\u7528dict()\u51fd\u6570&#xff0c;\u7ed9\u5065\u76f4\u63a5\u8d4b\u503c<\/td>\n<td>\n<p>x&#061;dict(a&#061;1,b&#061;2,c&#061;3)\n<\/td>\n<\/tr>\n<tr>\n<td>\u2462<\/td>\n<td>dict(\u53ef\u8fed\u4ee3\u5bf9\u8c61)<\/td>\n<td>\u5229\u7528\u5217\u8868\u5d4c\u5957\u5143\u7ec4\u7684\u65b9\u6cd5&#xff0c;\u751f\u6210\u53ef\u8fed\u4ee3\u5bf9\u8c61<\/td>\n<td>\n<p># \u5916\u5c42&#xff1a;\u5217\u8868&#xff08;\u53ef\u8fed\u4ee3&#xff09;<br \/>\n# \u5185\u5c42\u6bcf\u4e00\u9879&#xff1a;\u4e8c\u5143\u5143\u7ec4 (\u952e,\u503c)<br \/>\nx &#061; [(&#034;a&#034;,1), (&#034;b&#034;,2)(&#034;c&#034;,3)]<br \/>\ny &#061; dict(x)\n<\/td>\n<\/tr>\n<tr>\n<td>\u2463<\/td>\n<td>dict.fromkeys()<\/td>\n<td>\u5feb\u901f\u521d\u59cb\u5316\u76f8\u540c\u7684\u503c<\/td>\n<td>\n<p>x&#061;dict.fromkeys([&#034;a&#034;,&#034;b&#034;,&#034;c&#034;],0)<br \/>\n#{&#034;a&#034;:0,&#034;b&#034;:0,&#034;c&#034;:0}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2464<\/td>\n<td>x&#061;{}<\/td>\n<td>\u7a7a\u5b57\u5178\u7684\u751f\u6210<\/td>\n<td>\n<p>x&#061;{}    #\u751f\u6210\u7684x\u5c31\u662f\u7a7a\u5b57\u5178\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e8c\u3001\u5b57\u5178\u7684\u589e\u5220\u6539\u67e5<\/h2>\n<h3>1.\u589e\/\u6539&#xff08;\u589e\u52a0\/\u4fee\u6539\u5143\u7d20&#xff09;<\/h3>\n<p>\u82e5key\u5b58\u5728&#xff0c;\u5219\u4fee\u6539value\u503c&#xff0c;\u82e5key\u4e0d\u5b58\u5728&#xff0c;\u5219\u65b0\u589e\u4e00\u4e2a\u952e\u503c\u5bf9\u3002<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>\u4fee\u6539\u5143\u7d20<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nx[&#034;a&#034;]&#061;100<br \/>\nprint(x)<br \/>\n#{&#034;a&#034;:100,&#034;b&#034;:2,&#034;c&#034;:3}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>\u65b0\u589e\u5143\u7d20<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3,}<br \/>\nx[&#034;D&#034;]&#061;4<br \/>\nprint(x)<br \/>\n#{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3,&#034;D&#034;:4}\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.\u5220&#xff08;\u5220\u9664\u5143\u7d20&#xff09;<\/h3>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u65b9\u6cd5<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>del x[key]<\/td>\n<td>\u5229\u7528del\u65b9\u6cd5&#xff0c;\u5220\u9664\u56fa\u5b9a\u952e\u503c\u5bf9<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ndel x[&#034;a&#034;]<br \/>\nprint(x)<br \/>\n#{&#034;b&#034;:2,&#034;c&#034;:3}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>x.pop(key&#xff0c;\u9ed8\u8ba4\u503c)<\/td>\n<td>\u82e5\u4e0d\u8bbe\u7f6e\u9ed8\u8ba4\u503c&#xff0c;\u5220\u9664\u540e\u8fd4\u56devalue&#xff0c;\u6ca1\u6709\u5bf9\u5e94\u7684key\u5219\u62a5\u9519&#xff1b;\u82e5\u8bbe\u7f6e\u9ed8\u8ba4\u503c&#xff0c;\u6ca1\u6709\u5bf9\u5e94\u7684key\u4e0d\u62a5\u9519&#xff0c;\u8fd4\u56de\u9ed8\u8ba4\u503c\u3002<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ny&#061;x.pop(&#034;a&#034;)<br \/>\nprint(y)<br \/>\n#1<\/p>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ny&#061;x.pop(&#034;d&#034;,0)<br \/>\nprint(y)<br \/>\n#0\n<\/td>\n<\/tr>\n<tr>\n<td>\u2462<\/td>\n<td>x.popitem()<\/td>\n<td>\u5220\u9664\u6700\u540e\u63d2\u5165\u7684\u952e\u503c\u5bf9&#xff0c;\u8fd4\u56de\u5143\u7ec4(key,value)<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ny&#061;x.popitem()<br \/>\nprint(y)<br \/>\n#(&#039;c&#039;,3)\n<\/td>\n<\/tr>\n<tr>\n<td>\u2463<\/td>\n<td>x.clear()<\/td>\n<td>\u6e05\u7a7a\u5b57\u5178\u4e2d\u6240\u6709\u7684\u5143\u7d20&#xff0c;\u4fdd\u7559\u5b57\u5178\u5bf9\u8c61<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nx.clear()<br \/>\nprint(x)<br \/>\n#{}\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3.\u67e5&#xff08;\u67e5\u627e\/\u83b7\u53d6\u5143\u7d20&#xff09;<\/h3>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u65b9\u6cd5<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>x[key]<\/td>\n<td>\u5229\u7528key\u7d22\u5f15\u83b7\u53d6\u76f8\u5e94\u7684\u503c&#xff0c;\u82e5key\u4e0d\u5b58\u5728\u5219\u62a5\u9519<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(x[&#034;a&#034;])<br \/>\n#1<\/p>\n<p>print(x[&#034;d&#034;])<br \/>\n#\u62a5\u9519\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\">\u2461<\/td>\n<td rowspan=\"2\">x.get(key&#xff0c;\u9ed8\u8ba4\u503c)<\/td>\n<td>\u6ca1\u6709\u8f93\u5165\u9ed8\u8ba4\u503c\u65f6&#xff0c;\u82e5key\u4e0d\u5b58\u5728&#xff0c;\u5219\u62a5\u9519<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ny&#061;x.get(&#034;a&#034;)<br \/>\nprint(y)<br \/>\n#1<\/p>\n<p>y&#061;x.get(&#034;d&#034;)<br \/>\nprint(y)<br \/>\n#\u62a5\u9519\n<\/td>\n<\/tr>\n<tr>\n<td>\u8f93\u5165\u9ed8\u8ba4\u503c\u65f6&#xff0c;\u82e5key\u4e0d\u5b58\u5728&#xff0c;\u5219\u8f93\u51fa\u9ed8\u8ba4\u503c<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\ny&#061;x.get(&#034;d&#034;&#xff0c;0)<br \/>\nprint(y)<br \/>\n#0\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e09\u3001\u5b57\u5178\u7684\u904d\u5386\u53ca\u5176\u65b9\u6cd5<\/h2>\n<p>\u82e5\u4f60\u5b66\u4e60\u4e86\u524d\u9762\u7684\u96c6\u5408\u77e5\u8bc6&#xff0c;\u4f60\u5e94\u8be5\u5f88\u5bb9\u6613\u7406\u89e3\u904d\u5386\u662f\u4ec0\u4e48&#xff0c;\u5176\u5b9e\u904d\u5386\u5c31\u662f\u83b7\u53d6\u6240\u6709\u5143\u7d20\u3002\u4f46\u5bf9\u4e8e\u5b57\u5178\u6765\u8bf4&#xff0c;\u904d\u5386\u5e76\u4e0d\u4e00\u5b9a\u4ee3\u8868\u83b7\u53d6\u5168\u90e8\u7684\u5143\u7d20&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u83b7\u53d6\u5168\u90e8\u7684key&#xff0c;\u6216\u5219\u83b7\u53d6\u5168\u90e8\u7684value&#xff0c;\u8fd8\u53ef\u4ee5\u662f\u83b7\u53d6\u5168\u90e8\u7684\u952e\u503c\u5bf9\u7b49\u7b49<\/p>\n<p>\u4e0b\u9762\u662f\u5b57\u5178\u83b7\u53d6\u7684\u4e09\u5927\u65b9\u6cd5\u2b07\ufe0f<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u65b9\u6cd5<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>x.keys()<\/td>\n<td>\u83b7\u53d6\u5b57\u5178\u4e2d\u6240\u6709\u7684key<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(x.keys())<br \/>\n#dict_keys([&#039;a&#039;, &#039;b&#039;, &#039;c&#039;])\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>x.values()<\/td>\n<td>\u83b7\u53d6\u5b57\u5178\u4e2d\u6240\u6709\u7684value<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(x.values())<br \/>\n#dict_values([1, 2, 3])<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\u2462<\/td>\n<td>x.items()<\/td>\n<td>\u83b7\u53d6\u5b57\u5178\u4e2d\u6240\u6709\u7684\u952e\u503c\u5bf9\u5143\u7ec4(key,value)<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(x.items())<br \/>\n#dict_items([(&#039;a&#039;, 1), (&#039;b&#039;, 2), (&#039;c&#039;, 3)])\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u83b7\u53d6\u76f8\u5173\u5143\u7d20&#xff0c;\u5e76\u5b58\u50a8\u8d77\u6765\u3002\u4f46\u5982\u679c\u9700\u8981\u5b57\u5178\u904d\u5386&#xff08;\u4e00\u4e2a\u4e00\u4e2a\u7684\u83b7\u53d6\u5143\u7d20&#xff09;&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\u4e0efor\u5faa\u73af\u7ed3\u5408\u83b7\u53d6\u3002<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>\u5229\u7528for\u5faa\u73af&#xff0c;\u904d\u5386key<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nfor i in x.keys():<br \/>\n    print(i,x[i])<br \/>\n#a 1<br \/>\n#b 2<br \/>\n#c 3\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>\u5229\u7528for\u5faa\u73af&#xff0c;\u904d\u5386key\u548cvalue<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nfor a,b in x.items():<br \/>\n    print(f&#034;{a}&#061;{b}&#034;)<br \/>\n#a&#061;1<br \/>\n#b&#061;2<br \/>\n#c&#061;3\n<\/td>\n<\/tr>\n<tr>\n<td>\u2462<\/td>\n<td>\u5229\u7528for\u5faa\u73af&#xff0c;\u76f4\u63a5\u904d\u5386\u5b57\u5178&#xff0c;\u7cfb\u7edf\u9ed8\u8ba4\u904d\u5386key<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nfor i in x:<br \/>\n    print(i)<br \/>\n#a<br \/>\n#b<br \/>\n#c<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u56db\u3001\u5b57\u5178\u5e38\u7528\u5185\u7f6e\u51fd\u6570<\/h2>\n<p>\u4ee5\u4e0b\u5185\u7f6e\u65b9\u6cd5\u4e3b\u8981\u662f\u5408\u5e76\u5b57\u5178<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\">\n<tbody>\n<tr>\n<td>\u5e8f\u53f7<\/td>\n<td>\u65b9\u6cd5<\/td>\n<td>\u4f5c\u7528<\/td>\n<td>\u793a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td>\u2460<\/td>\n<td>x.updat(y&#xff09;<\/td>\n<td>\u5408\u5e76\u4e24\u4e2a\u5b57\u5178&#xff0c;\u5e76\u6c47\u603b\u7ed9x<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2}<br \/>\ny&#061;{&#034;c&#034;:3,&#034;d&#034;:4}<br \/>\nx.update(y)<br \/>\nprint(x)<br \/>\n#{&#039;a&#039;: 1, &#039;b&#039;: 2, &#039;c&#039;: 3, &#039;d&#039;: 4}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2461<\/td>\n<td>z&#061;x|y<\/td>\n<td>\u5408\u5e76\u4e24\u4e2a\u5b57\u5178&#xff0c;\u751f\u6210\u4e00\u4e2a\u65b0\u5b57\u5178&#xff0c;\u4e0d\u6539\u53d8\u539f\u5b57\u5178<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2}<br \/>\ny&#061;{&#034;c&#034;:3,&#034;d&#034;:4}<br \/>\nz&#061;x|y<br \/>\nprint(z)<br \/>\n#{&#039;a&#039;: 1, &#039;b&#039;: 2, &#039;c&#039;: 3, &#039;d&#039;: 4}\n<\/td>\n<\/tr>\n<tr>\n<td>\u2462<\/td>\n<td>x|&#061;y<\/td>\n<td>\u539f\u5730\u5408\u5e76\u4e24\u4e2a\u5b57\u5178<\/td>\n<td>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2}<br \/>\ny&#061;{&#034;c&#034;:3,&#034;d&#034;:4}<br \/>\nx|&#061;y<br \/>\nprint(x)<br \/>\n#{&#039;a&#039;: 1, &#039;b&#039;: 2, &#039;c&#039;: 3, &#039;d&#039;: 4}\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e94\u3001\u5224\u65ad\u5065\u662f\u5426\u5b58\u5728<\/h2>\n<p>\u5728\u5b57\u5178\u4e2d\u6211\u4eec\u53ef\u4ee5\u5229\u7528in\/not in\u7684\u65b9\u6cd5&#xff0c;\u5224\u65adkey\u662f\u5426\u5b58\u5728\u8be5\u5b57\u5178\u4e2d\u3002<\/p>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(&#034;a&#034; in x)<br \/>\n#True<\/p>\n<p>print(&#034;d&#034; in x)<br \/>\n#False<\/p>\n<p>\u4f46\u8981\u6ce8\u610f\u7684\u662f&#xff0c;in\/not in\u7684\u65b9\u6cd5\u5e76\u4e0d\u80fd\u5224\u65ad\u5b57\u5178\u4e2d\u7684\u503c&#xff08;value&#xff09;<\/p>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(1 in x)<br \/>\n#False,\u4e0d\u8bba\u503c\u662f\u5426\u5b58\u5728\u4e8e\u5b57\u5178\u4e2d&#xff0c;\u90fd\u4f1a\u8f93\u51faFalse<\/p>\n<p>\u5f53\u6211\u4eec\u8981\u7528in\/not in\u65b9\u6cd5\u5224\u65ad\u503c&#xff0c;\u5e94\u8be5\u8fd9\u6837\u5199<\/p>\n<p>x&#061;{&#034;a&#034;:1,&#034;b&#034;:2,&#034;c&#034;:3}<br \/>\nprint(1 in x.values())<br \/>\n#True<\/p>\n<h2>\u516d\u3001\u5b57\u5178\u63a8\u5bfc\u5f0f<\/h2>\n<p>\u4e4b\u524d\u6211\u4eec\u5b66\u4e60\u7684\u5217\u8868\u63a8\u5bfc\u5f0f\u548c\u96c6\u5408\u63a8\u5bfc\u5f0f&#xff0c;\u73b0\u5728\u7684\u5b57\u5178\u63a8\u5bfc\u5f0f\u4e5f\u548c\u90a3\u4e24\u4e2a\u5dee\u4e0d\u591a&#xff0c;\u53ea\u4e0d\u8fc7\u8868\u8fbe\u5f0f\u73b0\u5728\u9700\u8981\u4e24\u4e2a&#xff0c;\u4e00\u4e2akey\u8868\u8fbe\u5f0f&#xff0c;\u4e00\u4e2avalue\u8868\u8fbe\u5f0f\u3002<\/p>\n<h3>1.\u57fa\u672c\u63a8\u5bfc\u5f0f<\/h3>\n<p>{key\u8868\u8fbe\u5f0f: value\u8868\u8fbe\u5f0f for \u53d8\u91cf in \u53ef\u8fed\u4ee3\u5bf9\u8c61}<\/p>\n<p>\u524d\u9762\u90e8\u5206\u7531\u4e24\u4e2a\u8868\u8fbe\u5f0f\u751f\u6210\u7ed3\u679c&#xff0c;\u540e\u9762\u7684\u5faa\u73af\u4f9d\u6b21\u8f93\u51fa\u8303\u56f4\u5185\u6570\u636e&#xff0c;\u4e3e\u4e2a\u4f8b\u5b50<\/p>\n<p>x&#061;{i:i*2 for i in range(5)}<br \/>\nprint(x)<br \/>\n#{0: 0, 1: 2, 2: 4, 3: 6, 4: 8}<\/p>\n<h3>2.\u5e26\u5206\u652f\u7ed3\u6784\u63a8\u5bfc\u5f0f<\/h3>\n<p>{key\u8868\u8fbe\u5f0f: value\u8868\u8fbe\u5f0f for \u53d8\u91cf in \u53ef\u8fed\u4ee3\u5bf9\u8c61 if \u6761\u4ef6}<\/p>\n<p>\u5229\u7528if\u8bed\u53e5&#xff0c;\u7b5b\u9009\u4e0d\u9700\u8981\u7684\u90e8\u5206<\/p>\n<p>x&#061;{i:i*2 for i in range(10) if i&gt;5}<br \/>\nprint(x)<br \/>\n#{6: 12, 7: 14, 8: 16, 9: 18}<\/p>\n<p>\u8ddf\u5176\u4ed6\u5e8f\u5217\u7c7b\u578b\u76f8\u540c\u7684&#xff0c;\u5b57\u5178\u63a8\u5bfc\u5f0f\u4e3b\u8981\u4f5c\u7528\u4e5f\u662f\u66f4\u5feb\u7684\u751f\u6210\u5b57\u5178&#xff0c;\u800c\u4e0d\u662f\u4f7f\u7528\u4f20\u7edf\u7684for\u5faa\u73af\u751f\u6210\u3002\u5b57\u5178\u63a8\u5bfc\u5f0f\u5f53\u7136\u4e5f\u53ef\u4ee5\u7528\u5d4c\u5957\u7684\u5f62\u5f0f\u6765\u5199&#xff0c;\u5e76\u4e14\u6709\u591a\u4e2a\u5206\u652f\u7ed3\u6784\u642d\u914d&#xff0c;\u8bfb\u8005\u4eec\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u81ea\u7531\u642d\u914d\u3002<\/p>\n<p>\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u64cd\u4f5c\u5f62\u5f0f&#xff0c;\u4e0d\u8981\u4e3a\u4e86\u66f4\u9ad8\u7ea7\u7684\u5f62\u5f0f\u5c31\u523b\u610f\u5730\u4f7f\u7528\u5b83&#xff0c;\u56e0\u4e3apy\u8bb2\u7a76\u7684\u662f\u901a\u4fd7\u6613\u61c2\u7684\u5f62\u5f0f~<\/p>\n<h2>\u4e03\u3001\u5b57\u5178\u7684\u62f7\u8d1d\u95ee\u9898<\/h2>\n<p>\u62f7\u8d1d\u4e0e\u8d4b\u503c\u4e0d\u540c\u7684\u662f&#xff0c;\u62f7\u8d1d\u662f\u751f\u6210\u4e24\u4e2a\u4e0d\u540c\u5730\u5740\u7684\u5b57\u5178&#xff0c;\u800c\u8d4b\u503c\u662f\u751f\u6210\u4e24\u4e2a\u5730\u5740\u76f8\u540c\u7684\u5b57\u5178\u3002<\/p>\n<p>\u82e5\u5730\u5740\u76f8\u540c&#xff0c;\u5219\u53ea\u8981\u6709\u4e00\u4e2a\u5b57\u5178\u6539\u53d8&#xff0c;\u53e6\u4e00\u4e2a\u5c31\u4f1a\u8ddf\u7740\u6539\u53d8\u3002\u540c\u7406&#xff0c;\u5730\u5740\u4e0d\u540c\u7684\u5b57\u5178\u4e0d\u4f1a\u53d7\u53e6\u4e00\u4e2a\u7684\u6539\u53d8\u800c\u6539\u53d8\u3002<\/p>\n<h3>1.\u6d45\u62f7\u8d1d<\/h3>\n<p>\u62f7\u8d1d\u5b57\u5178\u6d45\u5c42\u5185\u5bb9&#xff0c;\u6d45\u5c42\u5730\u5740\u53d1\u751f\u6539\u53d8&#xff0c;\u6df1\u5c42\u5730\u5740\u4e0d\u53d8\u3002<\/p>\n<p>x &#061; {&#034;a&#034;: [1,2]}<br \/>\ny &#061; x.copy()<br \/>\nx[&#034;a&#034;].append(3)<br \/>\nprint(y)<br \/>\n#{&#034;a&#034;:[1,2,3]}<\/p>\n<p>\u4ee5\u4e0a\u4f8b\u5b50\u4f53\u73b0\u6211\u4eec\u7ed9x\u6d45\u62f7\u8d1d&#xff0c;\u751f\u6210y\u5b57\u5178&#xff0c;\u5e76\u5c06x\u6df1\u5c42\u5185\u5bb9\u6539\u53d8&#xff0c;y\u4e5f\u4f1a\u968f\u4e4b\u6539\u53d8&#xff0c;\u8fd9\u5c31\u4f53\u73b0x\u548cy\u5b9e\u9645\u4e0a\u6df1\u5c42\u5730\u5740\u662f\u540c\u4e00\u4e2a\u3002<\/p>\n<h3>2.\u6df1\u62f7\u8d1d<\/h3>\n<p>\u5229\u7528copy\u6a21\u5757\u7684deepcopy\u65b9\u6cd5&#xff0c;\u53ef\u4ee5\u7ed9\u5b57\u5178\u8fdb\u884c\u6df1\u62f7\u8d1d&#xff0c;\u8fd9\u6837\u5b57\u5178\u7684\u6d45\u5c42\u548c\u5d4c\u5957\u5c42\u5730\u5740\u90fd\u4f1a\u53d1\u751f\u6539\u53d8\u3002<\/p>\n<p>import copy<br \/>\nx&#061;{&#034;a&#034;:[1,2],&#034;b&#034;:[3,4]}<br \/>\ny&#061;copy.deepcopy(x)<br \/>\nx[&#034;a&#034;].append(5)<br \/>\nprint(x)<br \/>\nprint(y)<br \/>\n#{&#039;a&#039;: [1, 2, 5], &#039;b&#039;: [3, 4]}<br \/>\n#{&#039;a&#039;: [1, 2], &#039;b&#039;: [3, 4]}<\/p>\n<p>\u663e\u7136&#xff0c;\u8fd9\u6837x\u548cy\u5c31\u4e0d\u4f1a\u76f8\u7b49\u3002<\/p>\n<h2>\u516b\u3001\u603b\u7ed3<\/h2>\n<p>\u5229\u7528\u5b57\u5178\u6536\u96c6\u5927\u91cf\u5185\u5bb9&#xff0c;\u53ef\u4ee5\u8ba9\u6211\u4eec\u5feb\u901f\u83b7\u53d6\u6240\u9700\u7684\u503c&#xff0c;\u4e0d\u7528\u4e00\u4e2a\u4e00\u4e2a\u53bb\u67e5\u627e\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u901a\u8fc7morse\u5bc6\u7801&#xff0c;\u83b7\u53d6\u5bf9\u5e94\u7684\u5b57\u6bcd&#xff0c;\u8f93\u51fa\u201c\u52a0\u5bc6\u201c\u8bed\u53e5\u5bf9\u5e94\u7684\u82f1\u6587\u3002<\/p>\n<p>morse &#061; {<br \/>\n    &#039;a&#039;: &#039;.-&#039;, &#039;b&#039;: &#039;-&#8230;&#039;, &#039;c&#039;: &#039;-.-.&#039;, &#039;d&#039;: &#039;-..&#039;, &#039;e&#039;: &#039;.&#039;,<br \/>\n    &#039;f&#039;: &#039;..-.&#039;, &#039;g&#039;: &#039;&#8211;.&#039;, &#039;h&#039;: &#039;&#8230;.&#039;, &#039;i&#039;: &#039;..&#039;, &#039;j&#039;: &#039;.&#8212;&#039;,<br \/>\n    &#039;k&#039;: &#039;-.-&#039;, &#039;l&#039;: &#039;.-..&#039;, &#039;m&#039;: &#039;&#8211;&#039;, &#039;n&#039;: &#039;-.&#039;, &#039;o&#039;: &#039;&#8212;&#039;,<br \/>\n    &#039;p&#039;: &#039;.&#8211;.&#039;, &#039;q&#039;: &#039;&#8211;.-&#039;, &#039;r&#039;: &#039;.-.&#039;, &#039;s&#039;: &#039;&#8230;&#039;, &#039;t&#039;: &#039;-&#039;,<br \/>\n    &#039;u&#039;: &#039;..-&#039;, &#039;v&#039;: &#039;&#8230;-&#039;, &#039;w&#039;: &#039;.&#8211;&#039;, &#039;x&#039;: &#039;-..-&#039;, &#039;y&#039;: &#039;-.&#8211;&#039;, &#039;z&#039;: &#039;&#8211;..&#039;<br \/>\n}<br \/>\nreverse_morse &#061; {v: k for k, v in morse.items()}<br \/>\nmorse_str &#061; &#034;&#8230;. . .-.. .-.. &#8212;&#034;<br \/>\ncode_list &#061; morse_str.split()<br \/>\nres &#061; &#034;&#034;<br \/>\nfor code in code_list:<br \/>\n    res &#043;&#061; reverse_morse[code]<br \/>\nprint(res)<\/p>\n<p>#hello<\/p>\n<p>\u600e\u4e48\u6837&#xff0c;\u662f\u4e0d\u662f\u6bd4\u8089\u773c\u4e00\u4e2a\u4e2a\u5bf9\u5e94\u65b9\u4fbf\u5f88\u591a\u5462&#xff1f;<\/p>\n<p>\u591a\u591a\u52a8\u52a8\u4f60\u7684\u5c0f\u624b\u64cd\u4f5c\u4e00\u4e0b&#xff0c;\u4e5f\u8bb8\u4f60\u4e5f\u80fd\u591f\u8f7b\u677e\u5730\u5199\u4e00\u4e2a\u5f3a\u5927\u7684\u5b57\u5178~<\/p>\n<p>\u6700\u540e&#xff0c;\u611f\u8c22\u5927\u5bb6\u7684\u9605\u8bfb&#xff0c;\u5982\u679c\u4f60\u5bf9py\u7684\u5176\u4ed6\u77e5\u8bc6\u611f\u5174\u8da3&#xff0c;\u53ef\u4ee5\u770b\u770b\u6211\u7684\u5176\u4ed6\u535a\u5ba2&#xff0c;\u90a3\u91cc\u6709\u6e05\u6670\u7684\u8bb2\u89e3\u3002\u5982\u679c\u672c\u7bc7\u6587\u7ae0\u6709\u4ec0\u4e48\u4e0d\u8db3\u548c\u6f0f\u6d1e&#xff0c;\u5e0c\u671b\u5927\u5bb6\u53ef\u4ee5\u6307\u51fa&#xff0c;\u6211\u5c06\u7acb\u5373\u505a\u51fa\u6539\u6b63&#xff01;&#xff01;<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u5b66\u4e60python\u4e2d\u7684\u5b57\u5178&#xff0c;\u8fd9\u91cc\u7684\u5b57\u5178\u8ddf\u6211\u4eec\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u5b57\u5178\u5176\u5b9e\u662f\u4e00\u4e2a\u610f\u601d\u3002\u4f20\u7edf\u610f\u4e49\u7684\u5b57\u5178\u6709\u4e00\u4e2a\u67e5\u8be2\u754c\u9762&#xff0c;\u8fd9\u5bf9\u5e94\u7684\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u5065&#xff08;key&#xff09;&#xff1b;\u6bcf\u4e2a\u67e5\u8be2\u5bf9\u8c61\u6709\u5bf9\u5e94\u7684\u9875\u7801\u89e3\u6790&#xff0c;\u8fd9\u4e2a\u5bf9\u5e94\u7684\u89e3\u6790\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u503c&#xff08;value&#xff09;\u3002\u90a3\u4e48&#xff0c;\u4ec0\u4e48\u662f\u5065\u4ec0\u4e48\u662f\u503c&#xff1f;\u5b57\u5178\u53c8\u6709\u4ec0\u4e48\u4f5c\u7528&#xff1f;\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u5b66\u4e60\u2192\u4e00\u3001\u5b9a\u4e49\u5b57\u5178\u548c\u96c6\u5408\u4e00\u6837&amp;#xff0c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,190],"topic":[],"class_list":["post-84819","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/84819.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4eca\u5929\u6211\u4eec\u5b66\u4e60python\u4e2d\u7684\u5b57\u5178&#xff0c;\u8fd9\u91cc\u7684\u5b57\u5178\u8ddf\u6211\u4eec\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u5b57\u5178\u5176\u5b9e\u662f\u4e00\u4e2a\u610f\u601d\u3002\u4f20\u7edf\u610f\u4e49\u7684\u5b57\u5178\u6709\u4e00\u4e2a\u67e5\u8be2\u754c\u9762&#xff0c;\u8fd9\u5bf9\u5e94\u7684\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u5065&#xff08;key&#xff09;&#xff1b;\u6bcf\u4e2a\u67e5\u8be2\u5bf9\u8c61\u6709\u5bf9\u5e94\u7684\u9875\u7801\u89e3\u6790&#xff0c;\u8fd9\u4e2a\u5bf9\u5e94\u7684\u89e3\u6790\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u503c&#xff08;value&#xff09;\u3002\u90a3\u4e48&#xff0c;\u4ec0\u4e48\u662f\u5065\u4ec0\u4e48\u662f\u503c&#xff1f;\u5b57\u5178\u53c8\u6709\u4ec0\u4e48\u4f5c\u7528&#xff1f;\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u5b66\u4e60\u2192\u4e00\u3001\u5b9a\u4e49\u5b57\u5178\u548c\u96c6\u5408\u4e00\u6837&amp;#xff0c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84819.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T10:42:19+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84819.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84819.html\",\"name\":\"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T10:42:19+00:00\",\"dateModified\":\"2026-07-26T10:42:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84819.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84819.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84819.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/84819.html","og_locale":"zh_CN","og_type":"article","og_title":"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4eca\u5929\u6211\u4eec\u5b66\u4e60python\u4e2d\u7684\u5b57\u5178&#xff0c;\u8fd9\u91cc\u7684\u5b57\u5178\u8ddf\u6211\u4eec\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u5b57\u5178\u5176\u5b9e\u662f\u4e00\u4e2a\u610f\u601d\u3002\u4f20\u7edf\u610f\u4e49\u7684\u5b57\u5178\u6709\u4e00\u4e2a\u67e5\u8be2\u754c\u9762&#xff0c;\u8fd9\u5bf9\u5e94\u7684\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u5065&#xff08;key&#xff09;&#xff1b;\u6bcf\u4e2a\u67e5\u8be2\u5bf9\u8c61\u6709\u5bf9\u5e94\u7684\u9875\u7801\u89e3\u6790&#xff0c;\u8fd9\u4e2a\u5bf9\u5e94\u7684\u89e3\u6790\u5c31\u662fpy\u5b57\u5178\u4e2d\u7684\u503c&#xff08;value&#xff09;\u3002\u90a3\u4e48&#xff0c;\u4ec0\u4e48\u662f\u5065\u4ec0\u4e48\u662f\u503c&#xff1f;\u5b57\u5178\u53c8\u6709\u4ec0\u4e48\u4f5c\u7528&#xff1f;\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u5b66\u4e60\u2192\u4e00\u3001\u5b9a\u4e49\u5b57\u5178\u548c\u96c6\u5408\u4e00\u6837&amp;#xff0c","og_url":"https:\/\/www.wsisp.com\/helps\/84819.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T10:42:19+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/84819.html","url":"https:\/\/www.wsisp.com\/helps\/84819.html","name":"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T10:42:19+00:00","dateModified":"2026-07-26T10:42:19+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84819.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84819.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84819.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"python\u7684\u5b57\u5178\u77e5\u8bc6\u70b9"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=84819"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84819\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84819"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}