{"id":204771,"date":"2025-05-29T13:49:36","date_gmt":"2025-05-29T05:49:36","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204771\/"},"modified":"2025-05-29T13:49:36","modified_gmt":"2025-05-29T05:49:36","slug":"python-%e7%b1%bb%e6%96%b9%e6%b3%95%e8%a3%85%e9%a5%b0%e5%99%a8%ef%bc%9a%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e7%b1%bb-a-%e7%9a%84%e6%96%b9%e6%b3%95%e4%bd%9c%e4%b8%ba%e8%a3%85%e9%a5%b0%e5%99%a8%e5%b9%b6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204771\/","title":{"rendered":"Python \u7c7b\u65b9\u6cd5\u88c5\u9970\u5668\uff1a\u5982\u4f55\u4f7f\u7528\u7c7b A \u7684\u65b9\u6cd5\u4f5c\u4e3a\u88c5\u9970\u5668\u5e76\u8bbf\u95ee\u7c7b A\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u7c7b\u65b9\u6cd5\u88c5\u9970\u5668\uff1a\u5982\u4f55\u4f7f\u7528\u7c7b A \u7684\u65b9\u6cd5\u4f5c\u4e3a\u88c5\u9970\u5668\u5e76\u8bbf\u95ee\u7c7b A\uff1f<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300aPython \u7c7b\u65b9\u6cd5\u88c5\u9970\u5668\uff1a\u5982\u4f55\u4f7f\u7528\u7c7b A \u7684\u65b9\u6cd5\u4f5c\u4e3a\u88c5\u9970\u5668\u5e76\u8bbf\u95ee\u7c7b A\uff1f\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241115\/173167278967373ad5cebb4.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u7c7b\u65b9\u6cd5\u4e2d\u7684\u7c7b\u88c5\u9970\u5668<\/strong><\/p>\n<p>\u5728 python \u4e2d\uff0c\u53ef\u5426\u5c06\u7c7b\u65b9\u6cd5\u4f5c\u4e3a\u7c7b\u65b9\u6cd5\u4e2d\u7684\u88c5\u9970\u5668\uff1f<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u4f7f\u7528\u7c7b a \u7684\u65b9\u6cd5 b \u4f5c\u4e3a\u88c5\u9970\u5668\uff0c\u5e76\u5728\u65b9\u6cd5 b \u4e2d\u4f7f\u7528\u7c7b a\uff1f<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u5b9e\u73b0\u6b64\u529f\u80fd\uff1a<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u9759\u6001\u65b9\u6cd5<\/strong><\/p>\n<p>\u5c06\u65b9\u6cd5 fun_a \u5b9a\u4e49\u4e3a\u9759\u6001\u65b9\u6cd5\uff0c\u5e76\u4f7f\u7528\u8be5\u9759\u6001\u65b9\u6cd5\u4f5c\u4e3a\u88c5\u9970\u5668\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>class a:\n    @staticmethod\n    def fun_a(func):\n        ...\n\n    @fun_a\n    def fun_b(self):\n        ...<\/pre>\n<p><strong>\u65b9\u6cd5 2\uff1a\u5916\u90e8\u88c5\u9970\u5668<\/strong><\/p>\n<p>\u5c06\u65b9\u6cd5 fun_a \u5b9a\u4e49\u4e3a\u4e00\u4e2a\u88c5\u9970\u5668\u51fd\u6570\uff0c\u5e76\u5728\u7c7b\u7684\u5916\u90e8\u4f7f\u7528\u8be5\u88c5\u9970\u5668\u5bf9\u65b9\u6cd5 fun_b \u8fdb\u884c\u88c5\u9970\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>def fun_A(func):\n    ...\n\nclass A:\n    @fun_A\n    def fun_B(self):\n        ...<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300aPython \u7c7b\u65b9\u6cd5\u88c5\u9970\u5668\uff1a\u5982\u4f55\u4f7f\u7528\u7c7b A \u7684\u65b9\u6cd5\u4f5c\u4e3a\u88c5\u9970\u5668\u5e76\u8bbf\u95ee\u7c7b A\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u7c7b\u65b9\u6cd5\u88c5\u9970\u5668\uff1a\u5982\u4f55&#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-204771","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204771","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=204771"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204771\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}