{"id":1110986,"date":"2025-01-08T17:24:53","date_gmt":"2025-01-08T09:24:53","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1110986.html"},"modified":"2025-01-08T17:24:55","modified_gmt":"2025-01-08T09:24:55","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%ae%9a%e4%b9%89%e6%b2%a1%e6%9c%89%e8%bf%94%e5%9b%9e%e5%80%bc%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1110986.html","title":{"rendered":"\u5982\u4f55\u7528python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u51fd\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25073618\/46eaf810-c388-4697-91eb-dfb187e194c3.webp\" alt=\"\u5982\u4f55\u7528python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u51fd\u6570\" \/><\/p>\n<p><p> <strong>\u7528Python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u51fd\u6570\u7684\u65b9\u6cd5\uff1a\u4f7f\u7528 <code>def<\/code> \u5173\u952e\u5b57\u3001\u51fd\u6570\u4f53\u4e2d\u4e0d\u4f7f\u7528 <code>return<\/code> \u8bed\u53e5\u3001\u8fd4\u56de\u503c\u9ed8\u8ba4\u4e3a <code>None<\/code>\u3002<\/strong> Python\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u51fd\u6570\u4f53\u4e2d\u4e0d\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\u5373\u53ef\u3002\u5373\u4f7f\u5728\u6ca1\u6709\u663e\u5f0f\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\u7684\u60c5\u51b5\u4e0b\uff0cPython\u51fd\u6570\u4f9d\u7136\u4f1a\u9690\u5f0f\u5730\u8fd4\u56de<code>None<\/code>\u3002\u8fd9\u4e00\u7279\u6027\u4f7f\u5f97\u6211\u4eec\u80fd\u591f\u521b\u5efa\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u7684\u51fd\u6570\uff0c\u800c\u4e0d\u9700\u8981\u5173\u5fc3\u8fd4\u56de\u503c\u3002<\/p>\n<\/p>\n<p><p>\u4e0b\u9762\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u5982\u4f55\u7528Python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff0c\u7406\u89e3\u5176\u5de5\u4f5c\u673a\u5236\uff0c\u5e76\u8ba8\u8bba\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u57fa\u672c\u5b9a\u4e49<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5b9a\u4e49\u51fd\u6570\u4f7f\u7528<code>def<\/code>\u5173\u952e\u5b57\uff0c\u540e\u8ddf\u51fd\u6570\u540d\u548c\u53c2\u6570\u5217\u8868\u3002\u51fd\u6570\u4f53\u5305\u542b\u4e00\u7cfb\u5217\u7684\u8bed\u53e5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def greet(name):<\/p>\n<p>    print(f&quot;Hello, {name}!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>greet<\/code>\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570<code>name<\/code>\uff0c\u5e76\u6253\u5370\u51fa\u4e00\u4e2a\u95ee\u5019\u6d88\u606f\u3002\u8fd9\u4e2a\u51fd\u6570\u6ca1\u6709\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\uff0c\u56e0\u6b64\u5b83\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u9690\u5f0f\u5730\u8fd4\u56de<code>None<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u51fd\u6570\u4e0d\u8fd4\u56de\u503c\u7684\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><h4>1. \u6253\u5370\u6d88\u606f\u6216\u65e5\u5fd7<\/h4>\n<\/p>\n<p><p>\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u5e38\u7528\u4e8e\u6253\u5370\u6d88\u606f\u6216\u65e5\u5fd7\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def log_message(message):<\/p>\n<p>    print(f&quot;LOG: {message}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a<code>log_message<\/code>\u51fd\u6570\u7528\u4e8e\u6253\u5370\u65e5\u5fd7\u6d88\u606f\u3002\u5b83\u4e0d\u9700\u8981\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u53ea\u9700\u5c06\u6d88\u606f\u6253\u5370\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h4>2. \u4fee\u6539\u5168\u5c40\u53d8\u91cf\u6216\u6570\u636e\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u4e5f\u53ef\u4ee5\u7528\u4e8e\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u6216\u6570\u636e\u7ed3\u6784\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">counter = 0<\/p>\n<p>def increment_counter():<\/p>\n<p>    global counter<\/p>\n<p>    counter += 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>increment_counter<\/code>\u51fd\u6570\u4fee\u6539\u4e86\u5168\u5c40\u53d8\u91cf<code>counter<\/code>\u7684\u503c\uff0c\u800c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002<\/p>\n<\/p>\n<p><h4>3. \u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u800c\u4e0d\u9700\u8981\u8fd4\u56de\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def perform_operations():<\/p>\n<p>    operation1()<\/p>\n<p>    operation2()<\/p>\n<p>    operation3()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a<code>perform_operations<\/code>\u51fd\u6570\u8c03\u7528\u4e86\u4e09\u4e2a\u5176\u4ed6\u51fd\u6570\uff0c\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u800c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<p><h4>1. \u9690\u5f0f\u8fd4\u56de\u503c<code>None<\/code><\/h4>\n<\/p>\n<p><p>\u5373\u4f7f\u51fd\u6570\u6ca1\u6709\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\uff0cPython\u51fd\u6570\u4ecd\u7136\u4f1a\u9690\u5f0f\u8fd4\u56de<code>None<\/code>\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def do_nothing():<\/p>\n<p>    pass<\/p>\n<p>result = do_nothing()<\/p>\n<p>print(result)  # \u8f93\u51fa: None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>do_nothing<\/code>\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u4f46\u8c03\u7528\u5b83\u7684\u7ed3\u679c\u662f<code>None<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2. \u663e\u5f0f\u8fd4\u56de<code>None<\/code><\/h4>\n<\/p>\n<p><p>\u5c3d\u7ba1\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u4f1a\u9690\u5f0f\u8fd4\u56de<code>None<\/code>\uff0c\u4f60\u4e5f\u53ef\u4ee5\u663e\u5f0f\u5730\u8fd4\u56de<code>None<\/code>\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def do_nothing():<\/p>\n<p>    return None<\/p>\n<p>result = do_nothing()<\/p>\n<p>print(result)  # \u8f93\u51fa: None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u663e\u5f0f\u8fd4\u56de<code>None<\/code>\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u8ba9\u5176\u4ed6\u5f00\u53d1\u8005\u66f4\u6e05\u695a\u5730\u77e5\u9053\u51fd\u6570\u6ca1\u6709\u6709\u610f\u4e49\u7684\u8fd4\u56de\u503c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><h4>1. \u51fd\u6570\u540d\u5e94\u63cf\u8ff0\u884c\u4e3a<\/h4>\n<\/p>\n<p><p>\u51fd\u6570\u540d\u5e94\u63cf\u8ff0\u51fd\u6570\u7684\u884c\u4e3a\u6216\u76ee\u7684\u3002\u4f8b\u5982\uff0c<code>log_message<\/code>\u51fd\u6570\u540d\u6e05\u695a\u5730\u63cf\u8ff0\u4e86\u5b83\u7684\u884c\u4e3a\uff0c\u5373\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u6587\u6863\u5b57\u7b26\u4e32<\/h4>\n<\/p>\n<p><p>\u4e3a\u51fd\u6570\u6dfb\u52a0\u6587\u6863\u5b57\u7b26\u4e32\uff08docstring\uff09\uff0c\u63cf\u8ff0\u51fd\u6570\u7684\u7528\u9014\u548c\u53c2\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def greet(name):<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    \u6253\u5370\u95ee\u5019\u6d88\u606f\u3002<\/p>\n<p>    \u53c2\u6570:<\/p>\n<p>    name (str): \u8981\u95ee\u5019\u7684\u4eba\u7684\u540d\u5b57\u3002<\/p>\n<p>    &quot;&quot;&quot;<\/p>\n<p>    print(f&quot;Hello, {name}!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6587\u6863\u5b57\u7b26\u4e32\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h4>3. \u907f\u514d\u8fc7\u957f\u7684\u51fd\u6570<\/h4>\n<\/p>\n<p><p>\u5c3d\u91cf\u907f\u514d\u5b9a\u4e49\u8fc7\u957f\u7684\u51fd\u6570\uff0c\u5c06\u590d\u6742\u7684\u64cd\u4f5c\u62c6\u5206\u4e3a\u591a\u4e2a\u8f83\u5c0f\u7684\u51fd\u6570\u3002\u8fd9\u6837\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u793a\u4f8b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u4e8e\u591a\u4e2a\u573a\u666f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u4ee3\u7801<\/p>\n<h2><strong>\u6253\u5370\u95ee\u5019\u6d88\u606f<\/strong><\/h2>\n<p>def greet(name):<\/p>\n<p>    print(f&quot;Hello, {name}!&quot;)<\/p>\n<h2><strong>\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f<\/strong><\/h2>\n<p>def log_message(message):<\/p>\n<p>    print(f&quot;LOG: {message}&quot;)<\/p>\n<h2><strong>\u4fee\u6539\u5168\u5c40\u53d8\u91cf<\/strong><\/h2>\n<p>counter = 0<\/p>\n<p>def increment_counter():<\/p>\n<p>    global counter<\/p>\n<p>    counter += 1<\/p>\n<h2><strong>\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c<\/strong><\/h2>\n<p>def perform_operations():<\/p>\n<p>    greet(&quot;Alice&quot;)<\/p>\n<p>    log_message(&quot;Operation started&quot;)<\/p>\n<p>    increment_counter()<\/p>\n<p>    log_message(&quot;Operation completed&quot;)<\/p>\n<h2><strong>\u8c03\u7528\u51fd\u6570<\/strong><\/h2>\n<p>perform_operations()<\/p>\n<p>print(f&quot;Counter: {counter}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u56db\u4e2a\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff0c\u5e76\u8c03\u7528\u5b83\u4eec\u6765\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u6e05\u6670\u5730\u5206\u79bb\u4e0d\u540c\u7684\u529f\u80fd\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u7ed3\u6784\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u51fd\u6570\u4f53\u4e2d\u4e0d\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\u5373\u53ef\u3002\u8fd9\u7c7b\u51fd\u6570\u5728\u6253\u5370\u6d88\u606f\u3001\u8bb0\u5f55\u65e5\u5fd7\u3001\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u3001\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\u7b49\u573a\u666f\u4e2d\u975e\u5e38\u5e38\u89c1\u3002\u5728\u7f16\u5199\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u65f6\uff0c\u6ce8\u610f\u51fd\u6570\u540d\u5e94\u63cf\u8ff0\u884c\u4e3a\uff0c\u4f7f\u7528\u6587\u6863\u5b57\u7b26\u4e32\u63d0\u9ad8\u53ef\u8bfb\u6027\uff0c\u907f\u514d\u8fc7\u957f\u7684\u51fd\u6570\u3002\u901a\u8fc7\u8fd9\u4e9b\u6700\u4f73\u5b9e\u8df5\uff0c\u53ef\u4ee5\u7f16\u5199\u51fa\u66f4\u52a0\u6e05\u6670\u3001\u53ef\u7ef4\u62a4\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u5e0c\u671b\u901a\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u4f60\u80fd\u591f\u66f4\u597d\u5730\u7406\u89e3\u5982\u4f55\u7528Python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff0c\u5e76\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528\u8fd9\u4e9b\u77e5\u8bc6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u4ec0\u4e48\u662f\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff1f<\/strong><br \/>\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u662f\u6307\u5728\u6267\u884c\u5b8c\u5176\u5185\u90e8\u4ee3\u7801\u540e\uff0c\u4e0d\u4f1a\u901a\u8fc7<code>return<\/code>\u8bed\u53e5\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u8fd9\u7c7b\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\uff0c\u6bd4\u5982\u6253\u5370\u4fe1\u606f\u3001\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u6216\u5904\u7406\u6587\u4ef6\u7b49\uff0c\u800c\u4e0d\u9700\u8981\u5c06\u7ed3\u679c\u4f20\u9012\u56de\u8c03\u7528\u8005\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u975e\u5e38\u7b80\u5355\u3002\u60a8\u53ea\u9700\u4f7f\u7528<code>def<\/code>\u5173\u952e\u5b57\u5b9a\u4e49\u51fd\u6570\uff0c\u5e76\u5728\u51fd\u6570\u4f53\u5185\u7f16\u5199\u4ee3\u7801\uff0c\u800c\u4e0d\u4f7f\u7528<code>return<\/code>\u8bed\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">def greet(name):\n    print(f&quot;Hello, {name}!&quot;)\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>greet<\/code>\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570<code>name<\/code>\uff0c\u5e76\u6253\u5370\u51fa\u95ee\u5019\u8bed\uff0c\u4f46\u5e76\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002<\/p>\n<p><strong>\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u54ea\u4e9b\u573a\u666f\uff1f<\/strong><br \/>\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u5728\u8bb8\u591a\u573a\u666f\u4e2d\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u4eec\u6765\u5904\u7406\u7528\u6237\u8f93\u5165\u3001\u66f4\u65b0\u7a0b\u5e8f\u72b6\u6001\u3001\u6267\u884c\u6570\u636e\u5199\u5165\u64cd\u4f5c\u6216\u8fdb\u884c\u65e5\u5fd7\u8bb0\u5f55\u7b49\u3002\u8fd9\u4e9b\u51fd\u6570\u7684\u4e3b\u8981\u76ee\u7684\u662f\u6267\u884c\u67d0\u79cd\u884c\u4e3a\uff0c\u800c\u4e0d\u662f\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5\u4e00\u4e2a\u51fd\u6570\u662f\u5426\u6709\u8fd4\u56de\u503c\uff1f<\/strong><br \/>\u8981\u68c0\u67e5\u4e00\u4e2a\u51fd\u6570\u662f\u5426\u6709\u8fd4\u56de\u503c\uff0c\u53ef\u4ee5\u8c03\u7528\u8be5\u51fd\u6570\u5e76\u67e5\u770b\u5176\u8f93\u51fa\u3002\u5728Python\u4e2d\uff0c\u5982\u679c\u4e00\u4e2a\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u8c03\u7528\u8be5\u51fd\u6570\u5c06\u8fd4\u56de<code>None<\/code>\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">result = greet(&quot;Alice&quot;)\nprint(result)  # \u8f93\u51fa: None\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u60a8\u53ef\u4ee5\u786e\u8ba4\u8be5\u51fd\u6570\u662f\u4e00\u4e2a\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u5b9a\u4e49\u6ca1\u6709\u8fd4\u56de\u503c\u51fd\u6570\u7684\u65b9\u6cd5\uff1a\u4f7f\u7528 def \u5173\u952e\u5b57\u3001\u51fd\u6570\u4f53\u4e2d\u4e0d\u4f7f\u7528 return \u8bed\u53e5\u3001\u8fd4\u56de\u503c\u9ed8\u8ba4\u4e3a [&hellip;]","protected":false},"author":3,"featured_media":1110992,"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\/1110986"}],"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=1110986"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1110986\/revisions"}],"predecessor-version":[{"id":1110994,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1110986\/revisions\/1110994"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1110992"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1110986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1110986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1110986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}