{"id":204823,"date":"2025-05-29T08:47:28","date_gmt":"2025-05-29T00:47:28","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204823\/"},"modified":"2025-05-29T08:47:28","modified_gmt":"2025-05-29T00:47:28","slug":"python%e4%b8%adsupera-self-__init__%e5%92%8csuper-__init__%e7%9a%84%e5%8c%ba%e5%88%ab%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204823\/","title":{"rendered":"Python\u4e2dsuper(A, self).__init__()\u548csuper().__init__()\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python\u4e2dsuper(A, self).__init__()\u548csuper().__init__()\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f<\/h1>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300aPython\u4e2dsuper(A, self).__init__()\u548csuper().__init__()\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241117\/173181298167395e75d6207.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>super(A, self).__init__() \u548c super().__init__() \u7684\u533a\u522b<\/strong><\/p>\n<p>\u5728 Python \u4e2d\uff0csuper() \u5185\u7f6e\u51fd\u6570\u7528\u4e8e\u8c03\u7528\u7236\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3002<strong>\u5f53\u7c7b\u662f\u5355\u7ee7\u627f\u65f6\uff0csuper(A, self).__init__() \u548c super().__init__() \u57fa\u672c\u76f8\u540c<\/strong>\u3002<\/p>\n<p>\u7136\u800c\uff0c<strong>\u5728\u591a\u7ee7\u627f\u4e2d\uff0csuper(A, self).__init__() \u786e\u4fdd\u8c03\u7528\u7684\u662f A \u7c7b\u7684\u7236\u7c7b\u6784\u9020\u51fd\u6570<\/strong>\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0csuper().__init__() \u6ca1\u6709\u663e\u5f0f\u6307\u5b9a\u5f53\u524d\u7c7b\u548c\u5b9e\u4f8b\uff0c\u5b83\u4f1a\u81ea\u52a8\u4ece\u8c03\u7528\u5904\u7684\u4e0a\u4e0b\u6587\u4e2d\u63a8\u65ad\u3002<\/p>\n<p>\u5177\u4f53\u6765\u8bf4\uff1a<\/p>\n<ul>\n<li>super(A, self).__init__() \u663e\u5f0f\u5730\u6307\u5b9a\u4e86\u5f53\u524d\u7c7b\u4e3a A \u7c7b\uff0c\u786e\u4fdd\u8c03\u7528\u7684\u662f A \u7c7b\u7684\u7236\u7c7b\u6784\u9020\u51fd\u6570\u3002<\/li>\n<li>super().__init__() \u81ea\u52a8\u63a8\u65ad\u5f53\u524d\u7c7b\u548c\u5b9e\u4f8b\uff0c\u8c03\u7528\u4e0e\u4e0a\u4e0b\u6587\u76f8\u5339\u914d\u7684\u7236\u7c7b\u6784\u9020\u51fd\u6570\u3002<\/li>\n<\/ul>\n<p>\u5728\u5355\u6b21\u7ee7\u627f\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e24\u4e2a\u8c03\u7528\u7b49\u6548\u3002\u7136\u800c\uff0c\u5728\u591a\u7ee7\u627f\u4e2d\uff0c\u660e\u786e\u6307\u5b9a\u7236\u7c7b\u975e\u5e38\u91cd\u8981\uff0csuper(A, self).__init__() \u53ef\u4ee5\u63d0\u4f9b\u8fd9\u79cd\u660e\u786e\u6027\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u4e2dsuper(A, &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204823","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204823"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204823\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}