{"id":1150389,"date":"2025-01-13T17:00:58","date_gmt":"2025-01-13T09:00:58","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1150389.html"},"modified":"2025-01-13T17:01:01","modified_gmt":"2025-01-13T09:01:01","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%adpython%e5%8f%aa%e8%af%bb%e5%b1%9e%e6%80%a7","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1150389.html","title":{"rendered":"\u5982\u4f55\u5224\u65adpython\u53ea\u8bfb\u5c5e\u6027"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25180859\/8208c16a-df23-492f-9fdc-b7d67470209e.webp\" alt=\"\u5982\u4f55\u5224\u65adpython\u53ea\u8bfb\u5c5e\u6027\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027<\/strong>\uff1a<\/p>\n<\/p>\n<p><p><strong>\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528@property\u88c5\u9970\u5668\u3001\u68c0\u67e5\u5bf9\u8c61\u5c5e\u6027\u7684\u53ef\u53d8\u6027\u3001\u67e5\u770b\u6587\u6863\u6216\u6e90\u7801\u3001\u4f7f\u7528dir()\u51fd\u6570\u548c\u4f7f\u7528\u5185\u7f6e\u7684inspect\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4f7f\u7528@property\u88c5\u9970\u5668<\/strong>\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u4f7f\u7528@property\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u65b9\u6cd5\u8f6c\u6362\u4e3a\u4e00\u4e2a\u53ea\u8bfb\u5c5e\u6027\uff0c\u4ece\u800c\u907f\u514d\u5c5e\u6027\u88ab\u4fee\u6539\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c<code>value<\/code>\u5c5e\u6027\u88ab\u5b9a\u4e49\u4e3a\u53ea\u8bfb\u5c5e\u6027\u3002\u5982\u679c\u5c1d\u8bd5\u4fee\u6539\u8be5\u5c5e\u6027\uff0c\u5c06\u4f1a\u5f15\u53d1AttributeError\u9519\u8bef\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u89e3\u91ca\u5982\u4f55\u4f7f\u7528@property\u88c5\u9970\u5668\u6765\u5b9a\u4e49\u53ea\u8bfb\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001USING @PROPERTY DECORATOR<\/p>\n<\/p>\n<p><p>@property\u88c5\u9970\u5668\u662fPython\u4e2d\u5b9a\u4e49\u53ea\u8bfb\u5c5e\u6027\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u4f7f\u7528@property\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u65b9\u6cd5\u8f6c\u6362\u4e3a\u4e00\u4e2a\u53ea\u8bfb\u5c5e\u6027\uff0c\u4ece\u800c\u907f\u514d\u5c5e\u6027\u88ab\u4fee\u6539\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b9a\u4e49\u53ea\u8bfb\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c<code>value<\/code>\u5c5e\u6027\u88ab\u5b9a\u4e49\u4e3a\u53ea\u8bfb\u5c5e\u6027\u3002\u5982\u679c\u5c1d\u8bd5\u4fee\u6539\u8be5\u5c5e\u6027\uff0c\u5c06\u4f1a\u5f15\u53d1AttributeError\u9519\u8bef\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5c1d\u8bd5\u4fee\u6539\u53ea\u8bfb\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">obj = MyClass(10)<\/p>\n<p>print(obj.value)  # \u8f93\u51fa\uff1a10<\/p>\n<p>obj.value = 20    # AttributeError: can&#39;t set attribute<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528@property\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u9632\u6b62\u5c5e\u6027\u88ab\u4fee\u6539\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u68c0\u67e5\u5bf9\u8c61\u5c5e\u6027\u7684\u53ef\u53d8\u6027<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528@property\u88c5\u9970\u5668\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u5bf9\u8c61\u5c5e\u6027\u7684\u53ef\u53d8\u6027\u6765\u5224\u65ad\u662f\u5426\u4e3a\u53ea\u8bfb\u5c5e\u6027\u3002\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u5bf9\u8c61\u7684<code>__dict__<\/code>\u5c5e\u6027\u6216\u4f7f\u7528dir()\u51fd\u6570\u6765\u67e5\u770b\u5bf9\u8c61\u7684\u5c5e\u6027\u5217\u8868\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u67e5\u770b\u5bf9\u8c61\u7684__dict__\u5c5e\u6027<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p>obj = MyClass(10)<\/p>\n<p>print(obj.__dict__)  # \u8f93\u51fa\uff1a{&#39;_value&#39;: 10}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c<code>__dict__<\/code>\u5c5e\u6027\u5305\u542b\u4e86\u5bf9\u8c61\u7684\u6240\u6709\u53ef\u53d8\u5c5e\u6027\u3002\u7531\u4e8e<code>value<\/code>\u5c5e\u6027\u662f\u901a\u8fc7@property\u88c5\u9970\u5668\u5b9a\u4e49\u7684\uff0c\u53ea\u8bfb\u5c5e\u6027\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u5728<code>__dict__<\/code>\u5c5e\u6027\u4e2d\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528dir()\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p>obj = MyClass(10)<\/p>\n<p>print(dir(obj))  # \u8f93\u51fa\uff1a[&#39;_MyClass__value&#39;, &#39;__class__&#39;, &#39;__delattr__&#39;, &#39;__dict__&#39;, &#39;__dir__&#39;, &#39;__doc__&#39;, &#39;__eq__&#39;, &#39;__format__&#39;, &#39;__ge__&#39;, &#39;__getattribute__&#39;, &#39;__gt__&#39;, &#39;__hash__&#39;, &#39;__init__&#39;, &#39;__le__&#39;, &#39;__lt__&#39;, &#39;__module__&#39;, &#39;__ne__&#39;, &#39;__new__&#39;, &#39;__reduce__&#39;, &#39;__reduce_ex__&#39;, &#39;__repr__&#39;, &#39;__setattr__&#39;, &#39;__sizeof__&#39;, &#39;__str__&#39;, &#39;__subclasshook__&#39;, &#39;__weakref__&#39;, &#39;value&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cdir()\u51fd\u6570\u8fd4\u56de\u5bf9\u8c61\u7684\u6240\u6709\u5c5e\u6027\u5217\u8868\u3002\u7531\u4e8e<code>value<\/code>\u5c5e\u6027\u662f\u901a\u8fc7@property\u88c5\u9970\u5668\u5b9a\u4e49\u7684\uff0c\u53ea\u8bfb\u5c5e\u6027\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u5728<code>__dict__<\/code>\u5c5e\u6027\u4e2d\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u67e5\u770b\u6587\u6863\u6216\u6e90\u7801<\/p>\n<\/p>\n<p><p>\u67e5\u770b\u6587\u6863\u6216\u6e90\u7801\u4e5f\u662f\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\u7684\u6709\u6548\u65b9\u6cd5\u3002\u5728\u6587\u6863\u6216\u6e90\u7801\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u5c5e\u6027\u7684\u5b9a\u4e49\u65b9\u5f0f\u4ee5\u53ca\u662f\u5426\u4f7f\u7528@property\u88c5\u9970\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u67e5\u770b\u6587\u6863<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u67e5\u770b\u6587\u6863\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u5173\u952e\u5b57<code>@property<\/code>\u6765\u67e5\u627e\u53ea\u8bfb\u5c5e\u6027\u7684\u5b9a\u4e49\u3002\u4f8b\u5982\uff0c\u5728\u67e5\u770b\u67d0\u4e2a\u7c7b\u7684\u6587\u6863\u65f6\uff0c\u53ef\u4ee5\u641c\u7d22\u5173\u952e\u5b57<code>@property<\/code>\u6765\u67e5\u627e\u53ea\u8bfb\u5c5e\u6027\u7684\u5b9a\u4e49\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u67e5\u770b\u6e90\u7801<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u67e5\u770b\u6e90\u7801\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u5173\u952e\u5b57<code>@property<\/code>\u6765\u67e5\u627e\u53ea\u8bfb\u5c5e\u6027\u7684\u5b9a\u4e49\u3002\u4f8b\u5982\uff0c\u5728\u67e5\u770b\u67d0\u4e2a\u7c7b\u7684\u6e90\u7801\u65f6\uff0c\u53ef\u4ee5\u641c\u7d22\u5173\u952e\u5b57<code>@property<\/code>\u6765\u67e5\u627e\u53ea\u8bfb\u5c5e\u6027\u7684\u5b9a\u4e49\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u5185\u7f6e\u7684inspect\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u5185\u7f6e\u7684inspect\u6a21\u5757\u4e5f\u662f\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\u7684\u6709\u6548\u65b9\u6cd5\u3002\u901a\u8fc7\u4f7f\u7528inspect\u6a21\u5757\uff0c\u53ef\u4ee5\u67e5\u770b\u5bf9\u8c61\u7684\u5c5e\u6027\u5217\u8868\u4ee5\u53ca\u5c5e\u6027\u7684\u5b9a\u4e49\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u67e5\u770b\u5bf9\u8c61\u7684\u5c5e\u6027\u5217\u8868<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import inspect<\/p>\n<p>class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p>obj = MyClass(10)<\/p>\n<p>print(inspect.getmembers(obj))  # \u8f93\u51fa\uff1a[(&#39;__class__&#39;, &lt;class &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__.MyClass&#39;&gt;), (&#39;__delattr__&#39;, &lt;method-wrapper &#39;__delattr__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__dict__&#39;, {&#39;_value&#39;: 10}), (&#39;__dir__&#39;, &lt;built-in method __dir__ of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__doc__&#39;, None), (&#39;__eq__&#39;, &lt;method-wrapper &#39;__eq__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__format__&#39;, &lt;built-in method __format__ of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__ge__&#39;, &lt;method-wrapper &#39;__ge__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__getattribute__&#39;, &lt;method-wrapper &#39;__getattribute__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__gt__&#39;, &lt;method-wrapper &#39;__gt__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__hash__&#39;, &lt;method-wrapper &#39;__hash__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__init__&#39;, &lt;bound method MyClass.__init__ of &lt;__main__.MyClass object at 0x7f8b4c3c3b80&gt;&gt;), (&#39;__le__&#39;, &lt;method-wrapper &#39;__le__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__lt__&#39;, &lt;method-wrapper &#39;__lt__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__module__&#39;, &#39;__main__&#39;), (&#39;__ne__&#39;, &lt;method-wrapper &#39;__ne__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__new__&#39;, &lt;built-in method __new__ of type object at 0x10e6a8a40&gt;), (&#39;__reduce__&#39;, &lt;built-in method __reduce__ of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__reduce_ex__&#39;, &lt;built-in method __reduce_ex__ of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__repr__&#39;, &lt;method-wrapper &#39;__repr__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__setattr__&#39;, &lt;method-wrapper &#39;__setattr__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__sizeof__&#39;, &lt;built-in method __sizeof__ of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__str__&#39;, &lt;method-wrapper &#39;__str__&#39; of MyClass object at 0x7f8b4c3c3b80&gt;), (&#39;__subclasshook__&#39;, &lt;built-in method __subclasshook__ of type object at 0x10e6a8a40&gt;), (&#39;__weakref__&#39;, None), (&#39;value&#39;, 10)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cinspect.getmembers()\u51fd\u6570\u8fd4\u56de\u5bf9\u8c61\u7684\u6240\u6709\u5c5e\u6027\u5217\u8868\u3002\u7531\u4e8e<code>value<\/code>\u5c5e\u6027\u662f\u901a\u8fc7@property\u88c5\u9970\u5668\u5b9a\u4e49\u7684\uff0c\u53ea\u8bfb\u5c5e\u6027\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u5728<code>__dict__<\/code>\u5c5e\u6027\u4e2d\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u67e5\u770b\u5c5e\u6027\u7684\u5b9a\u4e49\u65b9\u5f0f<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import inspect<\/p>\n<p>class MyClass:<\/p>\n<p>    def __init__(self, value):<\/p>\n<p>        self._value = value<\/p>\n<p>    @property<\/p>\n<p>    def value(self):<\/p>\n<p>        return self._value<\/p>\n<p>obj = MyClass(10)<\/p>\n<p>print(inspect.getattr_static(obj, &#39;value&#39;))  # \u8f93\u51fa\uff1a&lt;property object at 0x7f8b4c3c3a90&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cinspect.getattr_static()\u51fd\u6570\u8fd4\u56de\u5c5e\u6027\u7684\u5b9a\u4e49\u65b9\u5f0f\u3002\u7531\u4e8e<code>value<\/code>\u5c5e\u6027\u662f\u901a\u8fc7@property\u88c5\u9970\u5668\u5b9a\u4e49\u7684\uff0c\u53ea\u8bfb\u5c5e\u6027\uff0c\u56e0\u6b64inspect.getattr_static()\u51fd\u6570\u8fd4\u56deproperty\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u5224\u65ad\u53ea\u8bfb\u5c5e\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u5b9a\u4e00\u4e2aPython\u5bf9\u8c61\u7684\u53ea\u8bfb\u5c5e\u6027\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u5bf9\u8c61\u7684\u5c5e\u6027\u5b9a\u4e49\u6765\u5224\u65ad\u3002\u901a\u5e38\uff0c\u53ea\u8bfb\u5c5e\u6027\u662f\u5728\u7c7b\u4e2d\u5b9a\u4e49\u4e3a\u79c1\u6709\u5c5e\u6027\uff08\u4ee5\u53cc\u4e0b\u5212\u7ebf\u5f00\u5934\uff09\uff0c\u5e76\u901a\u8fc7\u53ea\u8bfb\u7684getter\u65b9\u6cd5\u8fdb\u884c\u8bbf\u95ee\u3002\u4f7f\u7528<code>dir()<\/code>\u51fd\u6570\u53ef\u4ee5\u5217\u51fa\u5bf9\u8c61\u7684\u6240\u6709\u5c5e\u6027\uff0c\u7ed3\u5408<code>getattr()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c1d\u8bd5\u8bbf\u95ee\u8fd9\u4e9b\u5c5e\u6027\uff0c\u4ece\u800c\u5224\u65ad\u5b83\u4eec\u662f\u5426\u53ef\u4ee5\u88ab\u4fee\u6539\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5b9e\u73b0\u53ea\u8bfb\u5c5e\u6027\uff1f<\/strong><br \/>\u5b9e\u73b0\u53ea\u8bfb\u5c5e\u6027\u901a\u5e38\u4f1a\u4f7f\u7528@property\u88c5\u9970\u5668\u6765\u5b9a\u4e49\u4e00\u4e2a\u53ea\u8bfb\u7684getter\u65b9\u6cd5\uff0c\u800c\u4e0d\u63d0\u4f9bsetter\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u7c7b\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5c5e\u6027\uff0c\u901a\u8fc7@property\u88c5\u9970\u5668\u5c06\u5176\u5b9a\u4e49\u4e3a\u53ea\u8bfb\u3002\u8fd9\u79cd\u65b9\u5f0f\u80fd\u591f\u6709\u6548\u5730\u4fdd\u62a4\u5c5e\u6027\u4e0d\u88ab\u5916\u90e8\u4fee\u6539\u3002<\/p>\n<p><strong>\u5982\u679c\u60f3\u8981\u5c06\u5c5e\u6027\u8bbe\u4e3a\u53ea\u8bfb\uff0c\u662f\u5426\u9700\u8981\u4f7f\u7528\u79c1\u6709\u53d8\u91cf\uff1f<\/strong><br \/>\u4f7f\u7528\u79c1\u6709\u53d8\u91cf\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u505a\u6cd5\uff0c\u4f46\u5e76\u4e0d\u662f\u552f\u4e00\u7684\u9009\u62e9\u3002\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u53ea\u8bfb\u5c5e\u6027\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\uff0c\u5982\u679c\u6ca1\u6709\u63d0\u4f9bsetter\u65b9\u6cd5\uff0c\u5916\u90e8\u4ee3\u7801\u5c31\u65e0\u6cd5\u4fee\u6539\u8be5\u5c5e\u6027\u3002\u56e0\u6b64\uff0c\u79c1\u6709\u53d8\u91cf\u52a0\u4e0a@property\u88c5\u9970\u5668\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u4f46\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u6280\u672f\u624b\u6bb5\u6765\u786e\u4fdd\u5c5e\u6027\u7684\u53ea\u8bfb\u7279\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\uff1a \u5224\u65adPython\u53ea\u8bfb\u5c5e\u6027\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528@property\u88c5\u9970\u5668\u3001\u68c0\u67e5\u5bf9\u8c61\u5c5e\u6027 [&hellip;]","protected":false},"author":3,"featured_media":1150395,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1150389"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1150389"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1150389\/revisions"}],"predecessor-version":[{"id":1150397,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1150389\/revisions\/1150397"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1150395"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1150389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1150389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1150389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}