{"id":1119334,"date":"2025-01-08T18:43:43","date_gmt":"2025-01-08T10:43:43","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1119334.html"},"modified":"2025-01-08T18:43:46","modified_gmt":"2025-01-08T10:43:46","slug":"python%e5%a6%82%e4%bd%95%e8%ae%a9%e5%87%bd%e6%95%b0%e5%8f%aa%e6%89%a7%e8%a1%8c%e4%b8%80%e6%ac%a1","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1119334.html","title":{"rendered":"python\u5982\u4f55\u8ba9\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082454\/990bf065-0add-4c4f-8f79-745f2715d016.webp\" alt=\"python\u5982\u4f55\u8ba9\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u88c5\u9970\u5668\u3001\u5168\u5c40\u53d8\u91cf\u3001\u7c7b\u5c5e\u6027\u7b49\u65b9\u6cd5\u6765\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u88c5\u9970\u5668\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u5c06\u51fd\u6570\u7684\u884c\u4e3a\u8fdb\u884c\u4fee\u6539\uff0c\u800c\u4e0d\u6539\u53d8\u51fd\u6570\u672c\u8eab\u3002\u4ee5\u4e0b\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u4f7f\u7528\u88c5\u9970\u5668\u6765\u5b9e\u73b0\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u7684\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u88c5\u9970\u5668<\/p>\n<\/p>\n<p><p>\u88c5\u9970\u5668\u662f\u4e00\u79cd\u9ad8\u7ea7Python\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u4e0d\u6539\u53d8\u51fd\u6570\u672c\u8eab\u7684\u60c5\u51b5\u4e0b\u4fee\u6539\u5176\u884c\u4e3a\u3002\u901a\u8fc7\u4f7f\u7528\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u7684\u8981\u6c42\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def only_once(func):<\/p>\n<p>    has_run = False<\/p>\n<p>    def wrapper(*args, kwargs):<\/p>\n<p>        nonlocal has_run<\/p>\n<p>        if not has_run:<\/p>\n<p>            has_run = True<\/p>\n<p>            return func(*args, kwargs)<\/p>\n<p>        else:<\/p>\n<p>            print(&quot;This function has already been executed.&quot;)<\/p>\n<p>            return None<\/p>\n<p>    return wrapper<\/p>\n<p>@only_once<\/p>\n<p>def my_function():<\/p>\n<p>    print(&quot;Function is executed&quot;)<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u88c5\u9970\u5668\u7684\u4f18\u70b9\u662f\u7b80\u5355\u3001\u76f4\u89c2\u3001\u6613\u4e8e\u7ef4\u62a4\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u4e0d\u6539\u53d8\u51fd\u6570\u672c\u8eab\u7684\u60c5\u51b5\u4e0b\u5b9e\u73b0\u65b0\u7684\u529f\u80fd\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u5168\u5c40\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u88c5\u9970\u5668\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u6765\u63a7\u5236\u51fd\u6570\u7684\u6267\u884c\u6b21\u6570\u3002\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u5e76\u5728\u51fd\u6570\u5185\u90e8\u68c0\u67e5\u5176\u72b6\u6001\uff0c\u53ef\u4ee5\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">has_run = False<\/p>\n<p>def my_function():<\/p>\n<p>    global has_run<\/p>\n<p>    if not has_run:<\/p>\n<p>        has_run = True<\/p>\n<p>        print(&quot;Function is executed&quot;)<\/p>\n<p>    else:<\/p>\n<p>        print(&quot;This function has already been executed.&quot;)<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u7c7b\u5c5e\u6027<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u7c7b\u5c5e\u6027\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u7684\u6548\u679c\u3002\u901a\u8fc7\u5c06\u51fd\u6570\u5c01\u88c5\u5728\u7c7b\u4e2d\uff0c\u5e76\u4f7f\u7528\u7c7b\u5c5e\u6027\u6765\u8bb0\u5f55\u51fd\u6570\u7684\u6267\u884c\u72b6\u6001\uff0c\u53ef\u4ee5\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class MyClass:<\/p>\n<p>    has_run = False<\/p>\n<p>    @classmethod<\/p>\n<p>    def my_function(cls):<\/p>\n<p>        if not cls.has_run:<\/p>\n<p>            cls.has_run = True<\/p>\n<p>            print(&quot;Function is executed&quot;)<\/p>\n<p>        else:<\/p>\n<p>            print(&quot;This function has already been executed.&quot;)<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>MyClass.my_function()  # Output: Function is executed<\/p>\n<p>MyClass.my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u95ed\u5305<\/p>\n<\/p>\n<p><p>\u95ed\u5305\u662f\u4e00\u79cd\u51fd\u6570\u7f16\u7a0b\u6280\u672f\uff0c\u53ef\u4ee5\u6355\u83b7\u548c\u4fdd\u5b58\u5176\u4f5c\u7528\u57df\u4e2d\u7684\u5c40\u90e8\u53d8\u91cf\u3002\u901a\u8fc7\u4f7f\u7528\u95ed\u5305\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u53ea\u6267\u884c\u4e00\u6b21\u7684\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def only_once():<\/p>\n<p>    has_run = False<\/p>\n<p>    def inner_function():<\/p>\n<p>        nonlocal has_run<\/p>\n<p>        if not has_run:<\/p>\n<p>            has_run = True<\/p>\n<p>            print(&quot;Function is executed&quot;)<\/p>\n<p>        else:<\/p>\n<p>            print(&quot;This function has already been executed.&quot;)<\/p>\n<p>    return inner_function<\/p>\n<h2><strong>Creating the function<\/strong><\/h2>\n<p>my_function = only_once()<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f<\/p>\n<\/p>\n<p><p>\u5355\u4f8b\u6a21\u5f0f\u662f\u4e00\u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u786e\u4fdd\u67d0\u4e2a\u7c7b\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e2a\u5168\u5c40\u8bbf\u95ee\u70b9\u3002\u901a\u8fc7\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\uff0c\u53ef\u4ee5\u786e\u4fdd\u67d0\u4e2a\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Singleton:<\/p>\n<p>    _instance = None<\/p>\n<p>    def __new__(cls, *args, kwargs):<\/p>\n<p>        if not cls._instance:<\/p>\n<p>            cls._instance = super(Singleton, cls).__new__(cls, *args, kwargs)<\/p>\n<p>        return cls._instance<\/p>\n<p>    def __init__(self):<\/p>\n<p>        if not hasattr(self, &#39;has_run&#39;):<\/p>\n<p>            self.has_run = False<\/p>\n<p>    def my_function(self):<\/p>\n<p>        if not self.has_run:<\/p>\n<p>            self.has_run = True<\/p>\n<p>            print(&quot;Function is executed&quot;)<\/p>\n<p>        else:<\/p>\n<p>            print(&quot;This function has already been executed.&quot;)<\/p>\n<h2><strong>Creating the singleton instance<\/strong><\/h2>\n<p>singleton = Singleton()<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>singleton.my_function()  # Output: Function is executed<\/p>\n<p>singleton.my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528\u7ebf\u7a0b\u9501<\/p>\n<\/p>\n<p><p>\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u7ebf\u7a0b\u9501\uff08Lock\uff09\u6765\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u7ebf\u7a0b\u9501\u662f\u4e00\u79cd\u540c\u6b65\u539f\u8bed\uff0c\u7528\u4e8e\u9632\u6b62\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bbf\u95ee\u5171\u4eab\u8d44\u6e90\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>lock = threading.Lock()<\/p>\n<p>has_run = False<\/p>\n<p>def my_function():<\/p>\n<p>    global has_run<\/p>\n<p>    with lock:<\/p>\n<p>        if not has_run:<\/p>\n<p>            has_run = True<\/p>\n<p>            print(&quot;Function is executed&quot;)<\/p>\n<p>        else:<\/p>\n<p>            print(&quot;This function has already been executed.&quot;)<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u4f7f\u7528\u7ebf\u7a0b\u9501\uff0c\u53ef\u4ee5\u786e\u4fdd\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\uff0c\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\uff0c\u907f\u514d\u7ade\u4e89\u6761\u4ef6\u548c\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528\u51fd\u6570\u5c5e\u6027<\/p>\n<\/p>\n<p><p>\u51fd\u6570\u5c5e\u6027\u662fPython\u51fd\u6570\u7684\u4e00\u4e2a\u7279\u6027\uff0c\u53ef\u4ee5\u4e3a\u51fd\u6570\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5c5e\u6027\u3002\u901a\u8fc7\u4f7f\u7528\u51fd\u6570\u5c5e\u6027\uff0c\u53ef\u4ee5\u63a7\u5236\u51fd\u6570\u7684\u6267\u884c\u72b6\u6001\uff0c\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def my_function():<\/p>\n<p>    if not hasattr(my_function, &#39;has_run&#39;):<\/p>\n<p>        my_function.has_run = False<\/p>\n<p>    if not my_function.has_run:<\/p>\n<p>        my_function.has_run = True<\/p>\n<p>        print(&quot;Function is executed&quot;)<\/p>\n<p>    else:<\/p>\n<p>        print(&quot;This function has already been executed.&quot;)<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # Output: This function has already been executed.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528\u7f13\u5b58\u673a\u5236<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u7f13\u5b58\u673a\u5236\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u7684\u6548\u679c\u3002\u901a\u8fc7\u7f13\u5b58\u51fd\u6570\u7684\u6267\u884c\u7ed3\u679c\uff0c\u53ef\u4ee5\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\uff0c\u5e76\u5728\u540e\u7eed\u8c03\u7528\u4e2d\u76f4\u63a5\u8fd4\u56de\u7f13\u5b58\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from functools import lru_cache<\/p>\n<p>@lru_cache(maxsize=1)<\/p>\n<p>def my_function():<\/p>\n<p>    print(&quot;Function is executed&quot;)<\/p>\n<p>    return &quot;Result&quot;<\/p>\n<h2><strong>Testing the function<\/strong><\/h2>\n<p>my_function()  # Output: Function is executed<\/p>\n<p>my_function()  # No output, result is returned from cache<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\uff0c\u5305\u62ec<strong>\u88c5\u9970\u5668\u3001\u5168\u5c40\u53d8\u91cf\u3001\u7c7b\u5c5e\u6027\u3001\u95ed\u5305\u3001\u5355\u4f8b\u6a21\u5f0f\u3001\u7ebf\u7a0b\u9501\u3001\u51fd\u6570\u5c5e\u6027\u548c\u7f13\u5b58\u673a\u5236<\/strong>\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u88c5\u9970\u5668\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u5c06\u51fd\u6570\u7684\u884c\u4e3a\u8fdb\u884c\u4fee\u6539\uff0c\u800c\u4e0d\u6539\u53d8\u51fd\u6570\u672c\u8eab\u3002\u5168\u5c40\u53d8\u91cf\u548c\u7c7b\u5c5e\u6027\u9002\u7528\u4e8e\u7b80\u5355\u7684\u573a\u666f\uff0c\u800c\u95ed\u5305\u548c\u5355\u4f8b\u6a21\u5f0f\u5219\u9002\u7528\u4e8e\u66f4\u590d\u6742\u7684\u9700\u6c42\u3002\u7ebf\u7a0b\u9501\u7528\u4e8e\u591a\u7ebf\u7a0b\u73af\u5883\uff0c\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u51fd\u6570\u5c5e\u6027\u548c\u7f13\u5b58\u673a\u5236\u5219\u63d0\u4f9b\u4e86\u5176\u4ed6\u7075\u6d3b\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<p><p><strong>\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3001\u53ef\u7ef4\u62a4\u6027\u548c\u8fd0\u884c\u6548\u7387\u3002<\/strong><\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u786e\u4fdd\u51fd\u6570\u53ea\u88ab\u8c03\u7528\u4e00\u6b21\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u88c5\u9970\u5668\u6765\u786e\u4fdd\u4e00\u4e2a\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u88c5\u9970\u5668\u53ef\u4ee5\u5c01\u88c5\u51fd\u6570\u8c03\u7528\u7684\u903b\u8f91\uff0c\u5e76\u901a\u8fc7\u72b6\u6001\u53d8\u91cf\u6765\u63a7\u5236\u662f\u5426\u6267\u884c\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a<code>once<\/code>\u88c5\u9970\u5668\uff0c\u5728\u7b2c\u4e00\u6b21\u8c03\u7528\u65f6\u6267\u884c\u51fd\u6570\uff0c\u4e4b\u540e\u8fd4\u56de\u4e00\u4e2a\u5df2\u7f13\u5b58\u7684\u7ed3\u679c\u3002<\/p>\n<p><strong>\u4f7f\u7528\u4ec0\u4e48\u65b9\u6cd5\u53ef\u4ee5\u8bb0\u5f55\u51fd\u6570\u7684\u6267\u884c\u72b6\u6001\uff1f<\/strong><br \/>\u53ef\u4ee5\u5229\u7528Python\u4e2d\u7684\u95ed\u5305\u6765\u8bb0\u5f55\u51fd\u6570\u7684\u6267\u884c\u72b6\u6001\u3002\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u5185\u90e8\u51fd\u6570\u5e76\u5728\u5916\u90e8\u51fd\u6570\u4e2d\u4f7f\u7528\u53d8\u91cf\u6765\u4fdd\u5b58\u72b6\u6001\uff0c\u53ef\u4ee5\u786e\u4fdd\u5916\u90e8\u51fd\u6570\u5728\u6267\u884c\u540e\u4e0d\u518d\u8c03\u7528\u5185\u90e8\u51fd\u6570\u3002\u8fd9\u79cd\u65b9\u5f0f\u7b80\u6d01\u4e14\u6613\u4e8e\u7ef4\u62a4\u3002<\/p>\n<p><strong>\u662f\u5426\u6709\u5185\u7f6e\u7684\u5e93\u53ef\u4ee5\u5e2e\u52a9\u5b9e\u73b0\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u7684\u529f\u80fd\uff1f<\/strong><br \/>Python\u7684<code>functools<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86<code>lru_cache<\/code>\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u7f13\u5b58\u51fd\u6570\u7684\u8fd4\u56de\u503c\uff0c\u4ece\u800c\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u3002\u867d\u7136\u5b83\u7684\u4e3b\u8981\u7528\u9014\u662f\u7f13\u5b58\u7ed3\u679c\uff0c\u4f46\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5408\u9002\u7684\u53c2\u6570\u8bbe\u7f6e\u6765\u5b9e\u73b0\u53ea\u6267\u884c\u4e00\u6b21\u7684\u6548\u679c\u3002\u6b64\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u91cd\u590d\u8c03\u7528\u4f46\u7ed3\u679c\u4e0d\u53d8\u7684\u573a\u666f\u3002<\/p>\n<p><strong>\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\uff0c\u5982\u4f55\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\uff1f<\/strong><br \/>\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528<code>threading<\/code>\u6a21\u5757\u4e2d\u7684\u9501\uff08Lock\uff09\u6765\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u901a\u8fc7\u5728\u51fd\u6570\u5f00\u59cb\u65f6\u83b7\u53d6\u9501\uff0c\u786e\u4fdd\u540c\u4e00\u65f6\u95f4\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u6267\u884c\u8be5\u51fd\u6570\uff0c\u4ece\u800c\u907f\u514d\u6570\u636e\u7ade\u4e89\u548c\u4e0d\u4e00\u81f4\u7684\u72b6\u6001\u3002\u786e\u4fdd\u5728\u51fd\u6570\u7ed3\u675f\u65f6\u91ca\u653e\u9501\uff0c\u4ee5\u4fbf\u5176\u4ed6\u7ebf\u7a0b\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u88c5\u9970\u5668\u3001\u5168\u5c40\u53d8\u91cf\u3001\u7c7b\u5c5e\u6027\u7b49\u65b9\u6cd5\u6765\u786e\u4fdd\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u88c5\u9970\u5668\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848 [&hellip;]","protected":false},"author":3,"featured_media":1119341,"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\/1119334"}],"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=1119334"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119334\/revisions"}],"predecessor-version":[{"id":1119343,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1119334\/revisions\/1119343"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1119341"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1119334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1119334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1119334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}