{"id":1183401,"date":"2025-01-15T19:14:13","date_gmt":"2025-01-15T11:14:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1183401.html"},"modified":"2025-01-15T19:14:15","modified_gmt":"2025-01-15T11:14:15","slug":"%e5%a6%82%e4%bd%95%e4%b8%8d%e5%9c%a8python%e8%bf%90%e8%a1%8ccmd","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1183401.html","title":{"rendered":"\u5982\u4f55\u4e0d\u5728python\u8fd0\u884ccmd"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25133156\/76c3b2d3-cdba-4ccd-9318-5f810043084b.webp\" alt=\"\u5982\u4f55\u4e0d\u5728python\u8fd0\u884ccmd\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u8fd0\u884ccmd\u547d\u4ee4\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c\u4e3b\u8981\u5305\u62ec\uff1a\u4f7f\u7528subprocess\u6a21\u5757\u3001os.system\u51fd\u6570\u3001\u8c03\u7528\u7b2c\u4e09\u65b9\u5e93\u3001\u5229\u7528shell\u811a\u672c\u7b49\u3002<\/strong> \u5176\u4e2d\uff0csubprocess\u6a21\u5757\u662f\u6700\u5e38\u7528\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u63a7\u5236\u548c\u7075\u6d3b\u6027\uff0c\u9002\u7528\u4e8e\u590d\u6742\u7684\u547d\u4ee4\u6267\u884c\u548c\u7ed3\u679c\u5904\u7406\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528subprocess\u6a21\u5757\u8fd0\u884ccmd\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001SUBPROCESS\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>subprocess<\/code>\u6a21\u5757\u662fPython 3.x\u4e2d\u7528\u4e8e\u521b\u5efa\u65b0\u8fdb\u7a0b\u5e76\u4e0e\u5176\u8fdb\u884c\u901a\u4fe1\u7684\u6807\u51c6\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u66ff\u4ee3\u65e7\u7684<code>os.system<\/code>\u548c<code>os.popen<\/code>\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>subprocess.run<\/code>\u6267\u884c\u7b80\u5355\u7684\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u6267\u884ccmd\u547d\u4ee4\u5e76\u7b49\u5f85\u5b8c\u6210<\/strong><\/h2>\n<p>result = subprocess.run([&quot;echo&quot;, &quot;Hello, World!&quot;], capture_output=True, text=True)<\/p>\n<p>print(result.stdout)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>subprocess.run<\/code>\u6765\u6267\u884c<code>echo Hello, World!<\/code>\u547d\u4ee4\uff0c\u5e76\u6355\u83b7\u4e86\u8f93\u51fa\u3002<code>capture_output=True<\/code>\u8868\u793a\u6355\u83b7\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\uff0c<code>text=True<\/code>\u8868\u793a\u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u8fd4\u56de\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6267\u884c\u5e26\u53c2\u6570\u7684\u547d\u4ee4<\/h4>\n<\/p>\n<p><p>\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u6267\u884c\u5e26\u6709\u53c2\u6570\u7684\u547d\u4ee4\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u6267\u884c\u5e26\u53c2\u6570\u7684\u547d\u4ee4<\/strong><\/h2>\n<p>result = subprocess.run([&quot;ls&quot;, &quot;-l&quot;, &quot;\/usr&quot;], capture_output=True, text=True)<\/p>\n<p>print(result.stdout)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u6267\u884c\u4e86<code>ls -l \/usr<\/code>\u547d\u4ee4\uff0c\u5e76\u6253\u5370\u4e86\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6355\u83b7\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>subprocess.PIPE<\/code>\u6765\u6355\u83b7\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u6355\u83b7\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef<\/strong><\/h2>\n<p>result = subprocess.run([&quot;cat&quot;, &quot;non_existent_file&quot;], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)<\/p>\n<p>print(&quot;stdout:&quot;, result.stdout)<\/p>\n<p>print(&quot;stderr:&quot;, result.stderr)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6267\u884c\u4e86<code>cat non_existent_file<\/code>\u547d\u4ee4\uff0c\u7531\u4e8e\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u6211\u4eec\u6355\u83b7\u5230\u4e86\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u68c0\u67e5\u547d\u4ee4\u7684\u8fd4\u56de\u7801<\/h4>\n<\/p>\n<p><p>\u6267\u884c\u547d\u4ee4\u540e\uff0c\u53ef\u4ee5\u68c0\u67e5\u547d\u4ee4\u7684\u8fd4\u56de\u7801\u6765\u5224\u65ad\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u68c0\u67e5\u547d\u4ee4\u8fd4\u56de\u7801<\/strong><\/h2>\n<p>result = subprocess.run([&quot;ls&quot;, &quot;\/non_existent_directory&quot;], capture_output=True, text=True)<\/p>\n<p>if result.returncode == 0:<\/p>\n<p>    print(&quot;Command succeeded&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;Command f<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>led&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6267\u884c\u4e86<code>ls \/non_existent_directory<\/code>\u547d\u4ee4\uff0c\u7531\u4e8e\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c\u8fd4\u56de\u7801\u4e0d\u4e3a0\uff0c\u56e0\u6b64\u6253\u5370\u4e86&quot;Command failed&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001OS.SYSTEM\u51fd\u6570<\/h3>\n<\/p>\n<p><p><code>os.system<\/code>\u662fPython\u4e2d\u7528\u4e8e\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u7684\u4e00\u4e2a\u7b80\u5355\u65b9\u6cd5\uff0c\u4f46\u5b83\u7684\u529f\u80fd\u8f83\u4e3a\u6709\u9650\uff0c\u4e0d\u63a8\u8350\u7528\u4e8e\u590d\u6742\u7684\u547d\u4ee4\u6267\u884c\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>os.system<\/code>\u6267\u884c\u7b80\u5355\u7684\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<h2><strong>\u6267\u884ccmd\u547d\u4ee4<\/strong><\/h2>\n<p>os.system(&quot;echo Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>os.system<\/code>\u6765\u6267\u884c<code>echo Hello, World!<\/code>\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7f3a\u70b9<\/h4>\n<\/p>\n<p><p><code>os.system<\/code>\u4e0d\u80fd\u6355\u83b7\u547d\u4ee4\u7684\u8f93\u51fa\uff0c\u65e0\u6cd5\u5904\u7406\u590d\u6742\u7684\u547d\u4ee4\u6267\u884c\u548c\u7ed3\u679c\u5904\u7406\uff0c\u56e0\u6b64\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u63a8\u8350\u4f7f\u7528<code>subprocess<\/code>\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u8c03\u7528\u7b2c\u4e09\u65b9\u5e93<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7b2c\u4e09\u65b9\u5e93\u63d0\u4f9b\u4e86\u66f4\u9ad8\u5c42\u6b21\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6267\u884ccmd\u547d\u4ee4\uff0c\u4f8b\u5982<code>sh<\/code>\u5e93\u548c<code>invoke<\/code>\u5e93\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528sh\u5e93<\/h4>\n<\/p>\n<p><p><code>sh<\/code>\u5e93\u662f\u4e00\u4e2a\u7b80\u6d01\u7684\u547d\u4ee4\u6267\u884c\u5e93\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sh<\/p>\n<h2><strong>\u6267\u884ccmd\u547d\u4ee4<\/strong><\/h2>\n<p>print(sh.echo(&quot;Hello, World!&quot;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>sh.echo<\/code>\u6765\u6267\u884c<code>echo Hello, World!<\/code>\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528invoke\u5e93<\/h4>\n<\/p>\n<p><p><code>invoke<\/code>\u5e93\u662f\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6267\u884c\u547d\u4ee4\u548c\u7ba1\u7406\u4efb\u52a1\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from invoke import run<\/p>\n<h2><strong>\u6267\u884ccmd\u547d\u4ee4<\/strong><\/h2>\n<p>result = run(&quot;echo Hello, World!&quot;)<\/p>\n<p>print(result.stdout)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>invoke.run<\/code>\u6765\u6267\u884c<code>echo Hello, World!<\/code>\u547d\u4ee4\uff0c\u5e76\u6253\u5370\u4e86\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5229\u7528shell\u811a\u672c<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u5c06\u591a\u4e2a\u547d\u4ee4\u5199\u5165\u4e00\u4e2ashell\u811a\u672c\uff0c\u7136\u540e\u901a\u8fc7Python\u8c03\u7528\u8be5\u811a\u672c\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u5408\u6267\u884c\u8f83\u957f\u7684\u547d\u4ee4\u5e8f\u5217\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7f16\u5199shell\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u7f16\u5199\u4e00\u4e2ashell\u811a\u672c\uff0c\u4f8b\u5982<code>script.sh<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">#!\/bin\/bash<\/p>\n<p>echo &quot;Hello, World!&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5728Python\u4e2d\u8c03\u7528shell\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5728Python\u4e2d\u8c03\u7528\u8be5\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u8c03\u7528shell\u811a\u672c<\/strong><\/h2>\n<p>result = subprocess.run([&quot;.\/script.sh&quot;], capture_output=True, text=True)<\/p>\n<p>print(result.stdout)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u8c03\u7528\u4e86<code>script.sh<\/code>\u811a\u672c\uff0c\u5e76\u6253\u5370\u4e86\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u8fd0\u884ccmd\u547d\u4ee4\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c<strong>subprocess\u6a21\u5757\u662f\u6700\u5e38\u7528\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u65b9\u6cd5<\/strong>\u3002<code>subprocess.run<\/code>\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u53c2\u6570\uff0c\u53ef\u4ee5\u6355\u83b7\u8f93\u51fa\u3001\u68c0\u67e5\u8fd4\u56de\u7801\u7b49\u3002\u867d\u7136<code>os.system<\/code>\u65b9\u6cd5\u8f83\u4e3a\u7b80\u5355\uff0c\u4f46\u529f\u80fd\u6709\u9650\uff0c\u4e0d\u63a8\u8350\u7528\u4e8e\u590d\u6742\u7684\u547d\u4ee4\u6267\u884c\u573a\u666f\u3002\u7b2c\u4e09\u65b9\u5e93\u5982<code>sh<\/code>\u548c<code>invoke<\/code>\u63d0\u4f9b\u4e86\u66f4\u9ad8\u5c42\u6b21\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6267\u884c\u547d\u4ee4\u548c\u7ba1\u7406\u4efb\u52a1\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5c06\u591a\u4e2a\u547d\u4ee4\u5199\u5165shell\u811a\u672c\uff0c\u7136\u540e\u901a\u8fc7Python\u8c03\u7528\u8be5\u811a\u672c\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u6267\u884ccmd\u547d\u4ee4\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u800c\u4e0d\u76f4\u63a5\u4f7f\u7528CMD\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u800c\u4e0d\u5fc5\u76f4\u63a5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u4e2d\u64cd\u4f5c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u6a21\u5757\u5982<code>subprocess<\/code>\uff0c\u8be5\u6a21\u5757\u5141\u8bb8\u60a8\u5728Python\u811a\u672c\u4e2d\u8fd0\u884c\u5916\u90e8\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>subprocess.run()<\/code>\u6765\u6267\u884c\u547d\u4ee4\u5e76\u6355\u83b7\u8f93\u51fa\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import subprocess\n\nresult = subprocess.run([&#39;ls&#39;, &#39;-l&#39;], capture_output=True, text=True)\nprint(result.stdout)\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u5728Unix\/Linux\u7cfb\u7edf\u4e2d\u5217\u51fa\u5f53\u524d\u76ee\u5f55\u7684\u6587\u4ef6\uff0c\u800c\u65e0\u9700\u624b\u52a8\u6253\u5f00CMD\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u547d\u4ee4\u6267\u884c\u7684\u9519\u8bef\uff1f<\/strong><br \/>\u4f7f\u7528<code>subprocess<\/code>\u6a21\u5757\u65f6\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6355\u83b7\u5f02\u5e38\u6765\u5904\u7406\u547d\u4ee4\u6267\u884c\u4e2d\u7684\u9519\u8bef\u3002\u53ef\u4ee5\u4f7f\u7528<code>try-except<\/code>\u7ed3\u6784\u6765\u6355\u83b7<code>subprocess.CalledProcessError<\/code>\u5f02\u5e38\uff0c\u4ece\u800c\u66f4\u597d\u5730\u5904\u7406\u9519\u8bef\u60c5\u51b5\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import subprocess\n\ntry:\n    result = subprocess.run([&#39;some_command&#39;], check=True, capture_output=True, text=True)\n    print(result.stdout)\nexcept subprocess.CalledProcessError as e:\n    print(f&quot;\u547d\u4ee4\u6267\u884c\u5931\u8d25\uff0c\u9519\u8bef\u4fe1\u606f\uff1a{e.stderr}&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u60a8\u786e\u5b9a\u547d\u4ee4\u662f\u5426\u6210\u529f\u6267\u884c\uff0c\u5e76\u83b7\u53d6\u76f8\u5e94\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u83b7\u53d6\u5916\u90e8\u547d\u4ee4\u7684\u8f93\u51fa\uff1f<\/strong><br \/>\u8981\u83b7\u53d6\u5916\u90e8\u547d\u4ee4\u7684\u8f93\u51fa\uff0c<code>subprocess.run()<\/code>\u51fd\u6570\u7684<code>capture_output<\/code>\u53c2\u6570\u53ef\u4ee5\u8bbe\u7f6e\u4e3a<code>True<\/code>\uff0c\u8fd9\u6837\u60a8\u5c31\u80fd\u5728\u547d\u4ee4\u6267\u884c\u540e\u901a\u8fc7<code>result.stdout<\/code>\u83b7\u53d6\u6807\u51c6\u8f93\u51fa\uff0c\u800c\u901a\u8fc7<code>result.stderr<\/code>\u83b7\u53d6\u9519\u8bef\u8f93\u51fa\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import subprocess\n\nresult = subprocess.run([&#39;echo&#39;, &#39;Hello, World!&#39;], capture_output=True, text=True)\nprint(&quot;\u8f93\u51fa\uff1a&quot;, result.stdout)\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u4f1a\u5728Python\u7a0b\u5e8f\u4e2d\u6253\u5370\u51fa\u201cHello, World!\u201d\u7684\u8f93\u51fa\uff0c\u800c\u4e0d\u9700\u8981\u8fdb\u5165CMD\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u8fd0\u884ccmd\u547d\u4ee4\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff0c\u4e3b\u8981\u5305\u62ec\uff1a\u4f7f\u7528subprocess\u6a21\u5757\u3001os.system [&hellip;]","protected":false},"author":3,"featured_media":1183406,"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\/1183401"}],"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=1183401"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1183401\/revisions"}],"predecessor-version":[{"id":1183410,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1183401\/revisions\/1183410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1183406"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1183401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1183401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1183401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}