{"id":123173,"date":"2026-11-06T18:48:50","date_gmt":"2026-11-06T10:48:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123173.html"},"modified":"2026-11-06T18:48:50","modified_gmt":"2026-11-06T10:48:50","slug":"python-%e7%9a%84%e8%b5%8b%e5%80%bc%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e4%bc%9a%e5%a4%8d%e5%88%b6%e5%af%b9%e8%b1%a1%ef%bc%9f%e6%8b%86%e5%bc%80%e5%bc%95%e7%94%a8%e3%80%81%e6%b5%85%e6%8b%b7%e8%b4%9d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123173.html","title":{"rendered":"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d"},"content":{"rendered":"<p>CPython \u91cc\u6bcf\u4e2a\u53d8\u91cf\u540d\u90fd\u53ea\u662f\u6307\u5411\u67d0\u4e2a PyObject* \u7684\u5f15\u7528\u3002b &#061; a \u505a\u7684\u4e8b\u53ea\u6709\u4e00\u4ef6&#xff1a;\u628a a \u6307\u5411\u7684\u90a3\u4e2a\u6307\u9488\u6284\u7ed9 b&#xff0c;\u518d\u8c03\u7528\u4e00\u6b21 Py_INCREF \u628a\u5f15\u7528\u8ba1\u6570\u52a0\u4e00\u3002\u5bf9\u8c61\u672c\u8eab\u4e00\u4e2a\u5b57\u8282\u90fd\u6ca1\u52a8\u3002<br \/>\n\u5728\u89e3\u91ca\u5668\u91cc\u9a8c\u8bc1&#xff1a;python&gt;&gt;&gt; id(a) &#061;&#061; id(b)True&gt;&gt;&gt; sys.getrefcount(a)3    # a\u3001b&#xff0c;\u52a0\u4e0a\u4f20\u53c2\u4e34\u65f6\u6301\u6709\u7684\u4e00\u6b21\u5148\u770b\u4e00\u6bb5\u8ba9\u65b0\u624b\u5d29\u6e83\u7684id() \u76f8\u540c&#xff0c;\u8bf4\u660e a \u548c b \u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u7684\u4e24\u4e2a\u540d\u5b57\u3002\u6240\u8c13&#034;\u8d4b\u503c&#034;&#xff0c;\u672c\u8d28\u4e0a\u5c31\u662f\u628a 8 \u5b57\u8282\u7684\u6307\u9488\u6284\u4e86\u4e00\u904d\u2014\u2014\u8fd9\u4e5f\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48 Python \u91cc\u8d4b\u503c\u5feb\u5f97\u4e0d\u50cf\u8bdd\u3002<br \/>\n\u6240\u4ee5\u5f00\u5934\u90a3\u6bb5\u4ee3\u7801\u4e0d\u662f bug&#xff1a;b.append(4) \u64cd\u4f5c\u7684\u662f\u90a3\u4e2a\u552f\u4e00\u7684\u5217\u8868\u5bf9\u8c61&#xff0c;a \u548c b \u90fd\u6307\u7740\u5b83&#xff0c;\u5f53\u7136\u4e00\u8d77\u53d8\u3002## \u4e8c\u3001\u6d45\u62f7\u8d1d&#xff1a;\u53ea\u590d\u5236\u6700\u5916\u5c42\u60f3\u62ff\u5230\u72ec\u7acb\u526f\u672c&#xff0c;\u6700\u76f4\u63a5\u7684\u662f\u6d45\u62f7\u8d1d&#xff1a;pythonc &#061; a.copy()   # \u7b49\u4ef7\u4e8e a[:] \u548c list(a)\u4ee3\u7801&#xff1a;<\/p>\n<p>&#096;&#096;&#096;pythoninner &#061; [9]outer &#061; [inner]sh &#061; outer.copy()sh[0].append(8)print(outer[0])          # [9, 8] \u2014\u2014 \u5185\u5c42\u88ab\u5171\u4eab\u4e86print(outer is sh)       # False&#xff0c;\u5916\u5c42\u786e\u5b9e\u662f\u65b0\u5bf9\u8c61print(outer[0] is sh[0]) # True&#xff0c;\u5185\u5c42\u8fd8\u662f\u540c\u4e00\u4e2a&#096;&#096;&#096;ona &#061; [1, 2\u5b9e\u6d4b\u4e00\u7ec4\u6570\u636e&#xff08;CPython 3.13&#xff09;&#xff1a;2 \u4e07\u884c\u5d4c\u5957\u5217\u8868\u5360 9.3MB&#xff0c;\u6574\u4f53\u6d45\u62f7\u8d1d\u4e4b\u540e\u5185\u5b58\u53ea\u589e\u52a0 **0.16MB**\u2014\u2014\u589e\u52a0\u7684\u6b63\u662f 2 \u4e07\u4e2a\u6307\u9488\u69fd&#xff08;20,000 \u00d7 8 \u5b57\u8282 \u2248 156KB&#xff09;&#xff0c;\u6240\u6709\u5185\u5c42\u5bf9\u8c61\u539f\u5c01\u4e0d\u52a8\u5730\u5171\u4eab\u3002<br \/>\n\u6d45\u62f7\u8d1d\u7684\u771f\u6b63\u542b\u4e49&#xff1a;**\u5916\u5c42\u65b0&#xff0c;\u5185\u5c42\u65e7\u3002**## \u4e09\u3001\u6df1\u62f7\u8d1d&#xff1a;\u9012\u5f52\u5230\u5e95\u7684\u4ee3\u4ef7\u8981\u8fde\u5185\u5c42\u4e00\u8d77\u590d\u5236&#xff0c;\u5c31\u5f97\u7528 &#096;copy.deepcopy&#096;&#xff0c;\u5b83\u4f1a\u6cbf\u7740\u5f15\u7528\u4e00\u8def\u9012\u5f52\u4e0b\u53bb&#xff0c;\u628a\u6574\u68f5\u5bf9\u8c61\u6811\u590d\u5236\u4e00\u904d\u3002\u4ee3\u4ef7\u662f\u60ca\u4eba\u7684&#xff1a;&#096;&#096;&#096;pythonlst &#061; [{&#039;k&#039;: [i]*10} for i in range(2000)], 3]b &#061; a%timeit lst.copy()          # \u7ea6 0.010ms<br \/>\n%timeit copy.deepcopy(lst)  # \u7ea6 17.2ms&#096;&#096;&#096;\u540c\u6837 2000 \u4e2a\u5143\u7d20&#xff0c;\u6df1\u62f7\u8d1d\u6bd4\u6d45\u62f7\u8d1d\u6162\u4e86\u5927\u7ea6 **1700 \u500d**\u3002\u539f\u56e0\u5f88\u76f4\u767d&#xff1a;\u6d45\u62f7\u8d1d\u662f memcpy \u7ea7\u522b\u7684\u6307\u9488\u642c\u8fd0&#xff0c;\u6df1\u62f7\u8d1d\u8981\u5bf9\u6bcf\u4e2a\u5d4c\u5957\u5bf9\u8c61\u505a\u9012\u5f52\u904d\u5386\u3001\u9010\u4e2a\u65b0\u5efa\u3001\u7ef4\u62a4&#034;\u5df2\u590d\u5236&#034;\u5907\u5fd8\u5f55&#xff08;&#096;memo&#096; \u5b57\u5178&#xff0c;\u7528\u6765\u6b63\u786e\u5904\u7406\u5faa\u73af\u5f15\u7528\u548c\u5171\u4eab\u5b50\u5bf9\u8c61&#xff09;\u3002\u987a\u5e26\u8bf4\u4e00\u4e2a\u9ad8\u9891\u9762\u8bd5\u70b9&#xff1a;deepcopy \u4e4b\u6240\u4ee5\u80fd\u5904\u7406 &#096;x.append(x)&#096; \u8fd9\u79cd\u81ea\u5f15\u7528\u7ed3\u6784&#xff0c;\u9760\u7684\u5c31\u662f memo\u2014\u2014\u590d\u5236\u524d\u5148\u67e5&#034;\u8fd9\u4e2a\u5bf9\u8c61\u662f\u4e0d\u662f\u5df2\u7ecf\u590d\u5236\u8fc7\u4e86&#034;\u3002       ## \u56db\u3001\u51fd\u6570\u4f20\u53c2\u4e5f\u4e00\u6837&#xff1a;\u4f20\u7684\u662f\u5f15\u7528<br \/>\n&#096;&#096;&#096;pythondef fill(lst):    lst.append(1)data &#061; []fill(data)print(data)   # [1] \u2014\u2014 \u51fa\u4e86\u51fd\u6570\u8fd8\u5728&#096;&#096;&#096;Python \u7684\u53c2\u6570\u4f20\u9012\u5e38\u88ab\u53eb\u505a&#034;\u4f20\u5bf9\u8c61\u5f15\u7528&#034;&#xff1a;\u5f62\u53c2\u548c\u5b9e\u53c2\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u7684\u4e24\u4e2a\u540d\u5b57\u3002\u60f3\u907f\u514d\u51fd\u6570\u6c61\u67d3\u5916\u90e8\u6570\u636e&#xff0c;\u5165\u53e3\u5904\u5148 &#096;data &#061; data.copy()&#096;\u3002## \u4e94\u3001\u4e00\u4e2a\u5224\u65ad\u53e3\u8bc0\u6700\u540e\u7ed9\u4e00\u4e2a\u5b9e\u7528\u53e3\u8bc0&#xff0c;\u6309\u9700\u9009\u62f7\u8d1d\u6df1\u5ea6&#xff1a;- **\u5143\u7d20\u662f\u4e0d\u53ef\u53d8\u7c7b\u578b**&#xff08;\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5143\u7ec4&#xff09;&#xff1a;\u6d45\u62f7\u8d1d\u5c31\u591f&#xff0c;\u53cd\u6b63\u5b83\u4eec\u6539\u4e0d\u4e86&#xff1b;   # \u53ea\u662f\u8d4b\u503c&#xff0c;\u6ca1\u6709\u590d\u5236b.a- **\u4e00\u5c42\u5d4c\u5957\u3001\u53ea\u6539\u5916\u5c42**&#xff1a;\u6d45\u62f7\u8d1d&#xff1b;<br \/>\n&#8211; **\u5d4c\u5957\u53ef\u53d8\u5bf9\u8c61\u3001\u5404\u5c42\u90fd\u8981\u72ec\u7acb**&#xff1a;\u6df1\u62f7\u8d1d&#xff0c;\u4f46\u5148\u6382\u91cf\u90a3 1700 \u500d\u7684\u6027\u80fd\u5dee&#xff1b;- **\u53ea\u662f\u60f3\u4f20\u4e2a\u540d\u5b57**&#xff1a;\u76f4\u63a5\u8d4b\u503c&#xff0c;\u96f6\u6210\u672c\u3002\u8bb0\u4f4f\u6838\u5fc3\u673a\u5236\u5c31\u591f\u4e86&#xff1a;**Python \u91cc &#034;&#061;&#034; \u6c38\u8fdc\u53ea\u590d\u5236\u6307\u9488\u3002** \u590d\u5236\u5bf9\u8c61\u7684\u4efb\u4f55\u627f\u8bfa&#xff0c;\u90fd\u6765\u81ea &#096;copy&#096; \u6a21\u5757&#xff0c;\u800c\u4e0d\u662f\u8d4b\u503c\u8fd0\u7b97\u7b26\u672c\u8eab\u3002&#xff08;\u5b9e\u6d4b\u73af\u5883&#xff1a;CPython 3.13&#xff0c;Windows&#xff1b;\u4ee3\u7801\u53ef\u76f4\u63a5\u7c98\u8d34\u590d\u73b0&#xff09;ppend(4)print(a)       # [1, 2, 3, 4]  \u2014\u2014 a \u5c45\u7136\u4e5f\u53d8\u4e86&#096;&#096;&#096;&#096;b &#061; a&#096; \u4e00\u884c\u90fd\u6ca1&#034;\u6539\u9519&#034;&#xff0c;&#096;a&#096; \u5374\u88ab\u7275\u8fde\u4e86\u3002\u8981\u89e3\u91ca\u8fd9\u4ef6\u4e8b&#xff0c;\u5f97\u56de\u5230\u4e0a\u4e00\u671f\u8bb2\u8fc7\u7684\u90a3\u4e2a\u4e8b\u5b9e&#xff1a;**Python \u7684\u53d8\u91cf\u4e0d\u662f\u76d2\u5b50&#xff0c;\u662f\u6807\u7b7e\u3002**## \u4e00\u3001\u8d4b\u503c\u7684\u771f\u76f8&#xff1a;\u590d\u5236\u7684\u662f\u6307\u9488&#xff0c;\u4e0d\u662f\u5bf9\u8c61<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CPython \u91cc\u6bcf\u4e2a\u53d8\u91cf\u540d\u90fd\u53ea\u662f\u6307\u5411\u67d0\u4e2a PyObject* \u7684\u5f15\u7528\u3002b  a \u505a\u7684\u4e8b\u53ea\u6709\u4e00\u4ef6&#xff1a;\u628a a \u6307\u5411\u7684\u90a3\u4e2a\u6307\u9488\u6284\u7ed9 b&#xff0c;\u518d\u8c03\u7528\u4e00\u6b21 Py_INCREF \u628a\u5f15\u7528\u8ba1\u6570\u52a0\u4e00\u3002\u5bf9\u8c61\u672c\u8eab\u4e00\u4e2a\u5b57\u8282\u90fd\u6ca1\u52a8\u3002<br \/>\n\u5728\u89e3\u91ca\u5668\u91cc\u9a8c\u8bc1&#xff1a;python&gt;&gt;&gt; id(a)  id(b)True&gt;&gt;&gt; sys.getrefcount(a)3    # a\u3001b&#xff0c;\u52a0\u4e0a\u4f20\u53c2\u4e34\u65f6\u6301\u6709\u7684\u4e00\u6b21\u5148\u770b\u4e00\u6bb5\u8ba9\u65b0\u624b\u5d29\u6e83\u7684id() \u76f8\u540c&#xff0c;\u8bf4\u660e a \u548c <\/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-123173","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\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \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\/123173.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"CPython \u91cc\u6bcf\u4e2a\u53d8\u91cf\u540d\u90fd\u53ea\u662f\u6307\u5411\u67d0\u4e2a PyObject* \u7684\u5f15\u7528\u3002b a \u505a\u7684\u4e8b\u53ea\u6709\u4e00\u4ef6&#xff1a;\u628a a \u6307\u5411\u7684\u90a3\u4e2a\u6307\u9488\u6284\u7ed9 b&#xff0c;\u518d\u8c03\u7528\u4e00\u6b21 Py_INCREF \u628a\u5f15\u7528\u8ba1\u6570\u52a0\u4e00\u3002\u5bf9\u8c61\u672c\u8eab\u4e00\u4e2a\u5b57\u8282\u90fd\u6ca1\u52a8\u3002 \u5728\u89e3\u91ca\u5668\u91cc\u9a8c\u8bc1&#xff1a;python&gt;&gt;&gt; id(a) id(b)True&gt;&gt;&gt; sys.getrefcount(a)3  # a\u3001b&#xff0c;\u52a0\u4e0a\u4f20\u53c2\u4e34\u65f6\u6301\u6709\u7684\u4e00\u6b21\u5148\u770b\u4e00\u6bb5\u8ba9\u65b0\u624b\u5d29\u6e83\u7684id() \u76f8\u540c&#xff0c;\u8bf4\u660e a \u548c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123173.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-06T10:48:50+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123173.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123173.html\",\"name\":\"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-06T10:48:50+00:00\",\"dateModified\":\"2026-11-06T10:48:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123173.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123173.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123173.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d\"}]},{\"@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\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \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\/123173.html","og_locale":"zh_CN","og_type":"article","og_title":"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"CPython \u91cc\u6bcf\u4e2a\u53d8\u91cf\u540d\u90fd\u53ea\u662f\u6307\u5411\u67d0\u4e2a PyObject* \u7684\u5f15\u7528\u3002b a \u505a\u7684\u4e8b\u53ea\u6709\u4e00\u4ef6&#xff1a;\u628a a \u6307\u5411\u7684\u90a3\u4e2a\u6307\u9488\u6284\u7ed9 b&#xff0c;\u518d\u8c03\u7528\u4e00\u6b21 Py_INCREF \u628a\u5f15\u7528\u8ba1\u6570\u52a0\u4e00\u3002\u5bf9\u8c61\u672c\u8eab\u4e00\u4e2a\u5b57\u8282\u90fd\u6ca1\u52a8\u3002 \u5728\u89e3\u91ca\u5668\u91cc\u9a8c\u8bc1&#xff1a;python&gt;&gt;&gt; id(a) id(b)True&gt;&gt;&gt; sys.getrefcount(a)3  # a\u3001b&#xff0c;\u52a0\u4e0a\u4f20\u53c2\u4e34\u65f6\u6301\u6709\u7684\u4e00\u6b21\u5148\u770b\u4e00\u6bb5\u8ba9\u65b0\u624b\u5d29\u6e83\u7684id() \u76f8\u540c&#xff0c;\u8bf4\u660e a \u548c","og_url":"https:\/\/www.wsisp.com\/helps\/123173.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-06T10:48:50+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123173.html","url":"https:\/\/www.wsisp.com\/helps\/123173.html","name":"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-06T10:48:50+00:00","dateModified":"2026-11-06T10:48:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123173.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123173.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123173.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python \u7684\u8d4b\u503c\u4e3a\u4ec0\u4e48\u4e0d\u4f1a\u590d\u5236\u5bf9\u8c61\uff1f\u62c6\u5f00\u5f15\u7528\u3001\u6d45\u62f7\u8d1d\u4e0e\u6df1\u62f7\u8d1d"}]},{"@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\/123173","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=123173"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123173\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123173"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}