{"id":845,"date":"2024-11-07T15:41:32","date_gmt":"2024-11-07T07:41:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/845\/"},"modified":"2024-11-07T15:41:32","modified_gmt":"2024-11-07T07:41:32","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88-append-%e6%96%b9%e6%b3%95%e5%92%8c-%e5%9c%a8%e5%ae%9a%e4%b9%89%e5%87%bd%e6%95%b0%e6%97%b6%e5%a4%84%e7%90%86%e9%bb%98%e8%ae%a4%e5%8f%82%e6%95%b0%e7%9a%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/845\/","title":{"rendered":"\u4e3a\u4ec0\u4e48 append \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1064\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173000270273597.jpg\" width=\"800\" height=\"320\"+\" \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f-1\"+\" \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f-1\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173000270273597.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173000270273597-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173000270273597-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173000270273597-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"\u4e3a\u4ec0\u4e48 append \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48 append \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u51fd\u6570\u4e2d append \u4e0e &#8220;+&#8221; \u7684\u5dee\u5f02<\/strong><\/p>\n<p>\u5728\u5b9a\u4e49\u51fd\u6570\u65f6\uff0cappend \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u65b9\u9762\u8868\u73b0\u4e0d\u540c\u3002<\/p>\n<p><strong>append \u65b9\u6cd5<\/strong><\/p>\n<p>\u4f7f\u7528 append \u65b9\u6cd5\u65f6\uff0c\u5bf9\u9ed8\u8ba4\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u51fd\u6570\u7684\u540e\u7eed\u8c03\u7528\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>def zxc(a, b=[]):\n    b.append(a)\n    print(b)\n\nzxc(1)  # \u8f93\u51fa [1]\nzxc(2)  # \u8f93\u51fa [1, 2]<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u6bcf\u6b21\u8c03\u7528 zxc \u51fd\u6570\u90fd\u4f1a\u4fee\u6539\u9ed8\u8ba4\u53c2\u6570 b\uff0c\u5e76\u5728\u540e\u7eed\u8c03\u7528\u4e2d\u4f7f\u7528\u4fee\u6539\u540e\u7684\u503c\u3002<\/p>\n<p><strong>&#8220;+&#8221; \u65b9\u6cd5<\/strong><\/p>\n<p>\u76f8\u53cd\uff0c\u4f7f\u7528 &#8220;+&#8221; \u65b9\u6cd5\u65f6\uff0c\u5bf9\u9ed8\u8ba4\u53c2\u6570\u7684\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u51fd\u6570\u7684\u540e\u7eed\u8c03\u7528\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>def asd(a, b=[]):\n    b = [a] + b\n    print(b)\n\nasd(1)  # \u8f93\u51fa [1]\nasd(2)  # \u8f93\u51fa [2]<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5c3d\u7ba1\u5728 asd \u51fd\u6570\u4e2d\u91cd\u65b0\u5206\u914d\u4e86 b\uff0c\u4f46\u5b83\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684\u5217\u8868\uff0c\u4e0d\u4f1a\u5f71\u54cd\u540e\u7eed\u8c03\u7528\u4e2d\u4f7f\u7528\u7684\u9ed8\u8ba4\u503c\u3002<\/p>\n<p><strong>\u539f\u56e0<\/strong><\/p>\n<p>\u5dee\u5f02\u7684\u539f\u56e0\u5728\u4e8e &#8220;+&#8221; \u8fd0\u7b97\u7b26\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684\u5217\u8868\uff0c\u800c append \u65b9\u6cd5\u5219\u76f4\u63a5\u4fee\u6539\u73b0\u6709\u5217\u8868\u3002\u56e0\u6b64\uff0c\u53ea\u8981\u51fa\u73b0 b = \uff0cb \u5c31\u4e0d\u518d\u662f\u539f\u6765\u7684 b\uff0c\u800c\u662f\u4e00\u4e2a\u65b0\u5217\u8868\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e3a\u4ec0\u4e48 append \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u540c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570\u4e2d append \u4e0e &#8220;+&#8221; \u7684\u5dee\u5f02 \u5728\u5b9a\u4e49\u51fd\u6570\u65f6\uff0cappend \u65b9\u6cd5\u548c &#8220;+&#8221; \u5728\u5904\u7406\u9ed8\u8ba4\u53c2\u6570\u65b9\u9762\u8868\u73b0\u4e0d\u540c\u3002 append \u65b9\u6cd5 \u4f7f\u7528 append \u65b9\u6cd5\u65f6\uff0c\u5bf9\u9ed8\u8ba4\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u51fd\u6570\u7684\u540e\u7eed\u8c03\u7528\u3002\u4f8b\u5982\uff1a def zxc(a, b=[]): b.append(a) print(b) zxc(1) # \u8f93\u51fa [1] zxc(2) # \u8f93\u51fa [1, 2] \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u91cc\uff0c\u6bcf\u6b21\u8c03\u7528 zxc \u51fd\u6570\u90fd\u4f1a\u4fee\u6539\u9ed8\u8ba4\u53c2\u6570 b\uff0c\u5e76\u5728\u540e\u7eed\u8c03\u7528\u4e2d\u4f7f\u7528\u4fee\u6539\u540e\u7684\u503c\u3002 &#8220;+&#8221; \u65b9\u6cd5 \u76f8\u53cd\uff0c\u4f7f\u7528 &#8220;+&#8221; \u65b9\u6cd5\u65f6\uff0c\u5bf9\u9ed8\u8ba4\u53c2\u6570\u7684\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u51fd\u6570\u7684\u540e\u7eed\u8c03\u7528\u3002\u4f8b\u5982\uff1a def asd(a, b=[]): b = [a] + b print(b) asd(1) # \u8f93\u51fa [1] asd(2) # \u8f93\u51fa [2] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-845","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=845"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/845\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}