{"id":1184774,"date":"2025-01-15T19:30:39","date_gmt":"2025-01-15T11:30:39","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1184774.html"},"modified":"2025-01-15T19:30:44","modified_gmt":"2025-01-15T11:30:44","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e6%89%93%e5%bc%80%e7%b3%bb%e7%bb%9f%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1184774.html","title":{"rendered":"\u5982\u4f55\u7528python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25134121\/a3a676ba-57ad-462d-adf3-1980e85acae2.webp\" alt=\"\u5982\u4f55\u7528python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\" \/><\/p>\n<p><p> <strong>\u7528Python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528os\u6a21\u5757\u3001subprocess\u6a21\u5757\u4ee5\u53ca\u5176\u4ed6\u9ad8\u7ea7\u5e93\uff0c\u5982pywin32\u7b49\u3002<\/strong>\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528os\u6a21\u5757\u548csubprocess\u6a21\u5757\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u901a\u8fc7\u5b9e\u9645\u4ee3\u7801\u793a\u4f8b\u5e2e\u52a9\u8bfb\u8005\u7406\u89e3\u5982\u4f55\u4f7f\u7528Python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u3002\u9996\u5148\uff0c<strong>os\u6a21\u5757<\/strong>\u63d0\u4f9b\u4e86\u57fa\u672c\u7684\u7cfb\u7edf\u529f\u80fd\u8c03\u7528\uff0c<strong>subprocess\u6a21\u5757<\/strong>\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u548c\u5f3a\u5927\u7684\u8fdb\u7a0b\u7ba1\u7406\u529f\u80fd\uff0c<strong>pywin32\u5e93<\/strong>\u4e13\u7528\u4e8eWindows\u7cfb\u7edf\u7684\u9ad8\u7ea7\u529f\u80fd\u8c03\u7528\u3002\u4ee5\u4e0b\u662f\u8fd9\u4e9b\u65b9\u6cd5\u7684\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528os\u6a21\u5757<\/h3>\n<\/p>\n<p><h4>1.1 os.system()<\/h4>\n<\/p>\n<p><p>os\u6a21\u5757\u662fPython\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4ea4\u4e92\u7684\u529f\u80fd\u3002\u4f7f\u7528os.system()\u53ef\u4ee5\u76f4\u63a5\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528os.system()\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>os.system(&#39;calc&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>os.system(&#39;notepad&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>os.system()\u51fd\u6570\u4f1a\u5728\u5b50\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u7684\u547d\u4ee4\uff0c\u4f46\u5b83\u7684\u529f\u80fd\u8f83\u4e3a\u7b80\u5355\uff0c\u65e0\u6cd5\u83b7\u53d6\u5b50\u8fdb\u7a0b\u7684\u8f93\u51fa\uff0c\u4e5f\u4e0d\u80fd\u8fdb\u884c\u590d\u6742\u7684\u8fdb\u7a0b\u63a7\u5236\u3002<\/p>\n<\/p>\n<p><h4>1.2 os.startfile()<\/h4>\n<\/p>\n<p><p>os.startfile()\u662f\u4e13\u95e8\u7528\u4e8e\u5728Windows\u7cfb\u7edf\u4e0a\u6253\u5f00\u6587\u4ef6\u6216\u7a0b\u5e8f\u7684\u51fd\u6570\u3002\u5b83\u7684\u7528\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f20\u5165\u6587\u4ef6\u6216\u7a0b\u5e8f\u7684\u8def\u5f84\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>os.startfile(&#39;C:\\\\Windows\\\\System32\\\\calc.exe&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>os.startfile(&#39;C:\\\\Windows\\\\System32\\\\notepad.exe&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>os.startfile()\u51fd\u6570\u53ef\u4ee5\u81ea\u52a8\u9009\u62e9\u4e0e\u6587\u4ef6\u5173\u8054\u7684\u5e94\u7528\u7a0b\u5e8f\u6765\u6253\u5f00\u6587\u4ef6\uff0c\u975e\u5e38\u9002\u5408\u5728Windows\u7cfb\u7edf\u4e0a\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528subprocess\u6a21\u5757<\/h3>\n<\/p>\n<p><h4>2.1 subprocess.run()<\/h4>\n<\/p>\n<p><p>subprocess\u6a21\u5757\u662fPython 3.5\u5f15\u5165\u7684\u4e00\u4e2a\u66f4\u5f3a\u5927\u7684\u8fdb\u7a0b\u7ba1\u7406\u6a21\u5757\u3002\u5b83\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u63a5\u53e3\u6765\u521b\u5efa\u548c\u7ba1\u7406\u5b50\u8fdb\u7a0b\u3002subprocess.run()\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u6267\u884c\u547d\u4ee4\u5e76\u7b49\u5f85\u5176\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>subprocess.run([&#39;calc.exe&#39;])<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>subprocess.run([&#39;notepad.exe&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>subprocess.run()\u51fd\u6570\u8fd4\u56de\u4e00\u4e2aCompletedProcess\u5bf9\u8c61\uff0c\u5305\u542b\u4e86\u5b50\u8fdb\u7a0b\u7684\u8fd4\u56de\u7801\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u7b49\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h4>2.2 subprocess.Popen()<\/h4>\n<\/p>\n<p><p>subprocess.Popen()\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u7684\u8fdb\u7a0b\u63a7\u5236\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u4e0d\u963b\u585e\u4e3b\u8fdb\u7a0b\u7684\u60c5\u51b5\u4e0b\u542f\u52a8\u5b50\u8fdb\u7a0b\uff0c\u5e76\u4e0e\u5176\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>calc_process = subprocess.Popen([&#39;calc.exe&#39;])<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>notepad_process = subprocess.Popen([&#39;notepad.exe&#39;])<\/p>\n<h2><strong>\u7b49\u5f85\u8ba1\u7b97\u5668\u8fdb\u7a0b\u7ed3\u675f<\/strong><\/h2>\n<p>calc_process.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t()<\/p>\n<h2><strong>\u7b49\u5f85\u8bb0\u4e8b\u672c\u8fdb\u7a0b\u7ed3\u675f<\/strong><\/h2>\n<p>notepad_process.wait()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>subprocess.Popen()\u51fd\u6570\u8fd4\u56de\u4e00\u4e2aPopen\u5bf9\u8c61\uff0c\u901a\u8fc7\u8be5\u5bf9\u8c61\u53ef\u4ee5\u83b7\u53d6\u5b50\u8fdb\u7a0b\u7684PID\u3001\u8fd4\u56de\u7801\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u7b49\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528pywin32\u5e93<\/h3>\n<\/p>\n<p><p>pywin32\u5e93\u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8eWindows\u7cfb\u7edf\u7684Python\u5e93\uff0c\u63d0\u4f9b\u4e86\u5bf9Windows API\u7684\u8bbf\u95ee\u80fd\u529b\u3002\u4f7f\u7528pywin32\u5e93\u53ef\u4ee5\u5b9e\u73b0\u66f4\u9ad8\u7ea7\u7684\u7cfb\u7edf\u529f\u80fd\u8c03\u7528\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u5b89\u88c5pywin32\u5e93<\/h4>\n<\/p>\n<p><p>\u9996\u5148\u9700\u8981\u5b89\u88c5pywin32\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pywin32<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2 \u4f7f\u7528win32api.ShellExecute()<\/h4>\n<\/p>\n<p><p>pywin32\u5e93\u4e2d\u7684win32api\u6a21\u5757\u63d0\u4f9b\u4e86ShellExecute()\u51fd\u6570\uff0c\u53ef\u4ee5\u7528\u4e8e\u6253\u5f00\u6587\u4ef6\u6216\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import win32api<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>win32api.ShellExecute(0, &#39;open&#39;, &#39;calc.exe&#39;, None, None, 1)<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>win32api.ShellExecute(0, &#39;open&#39;, &#39;notepad.exe&#39;, None, None, 1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>ShellExecute()\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u7a97\u53e3\u53e5\u67c4\uff0c\u4f20\u51650\u8868\u793a\u4f7f\u7528\u5f53\u524d\u7a97\u53e3\uff1b\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u64cd\u4f5c\u7c7b\u578b\uff0c&#39;open&#39;\u8868\u793a\u6253\u5f00\u6587\u4ef6\u6216\u7a0b\u5e8f\uff1b\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u6587\u4ef6\u6216\u7a0b\u5e8f\u7684\u8def\u5f84\uff1b\u7b2c\u56db\u4e2a\u548c\u7b2c\u4e94\u4e2a\u53c2\u6570\u5206\u522b\u662f\u547d\u4ee4\u884c\u53c2\u6570\u548c\u5de5\u4f5c\u76ee\u5f55\uff1b\u7b2c\u516d\u4e2a\u53c2\u6570\u662f\u663e\u793a\u7a97\u53e3\u7684\u65b9\u5f0f\uff0c1\u8868\u793a\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5176\u4ed6\u9ad8\u7ea7\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7684\u9ad8\u7ea7\u65b9\u6cd5\u53ef\u4ee5\u7528\u4e8e\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u3002\u6bd4\u5982\u4f7f\u7528ctypes\u5e93\u76f4\u63a5\u8c03\u7528Windows API\uff0c\u6216\u8005\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982psutil\u8fdb\u884c\u8fdb\u7a0b\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h4>4.1 \u4f7f\u7528ctypes\u5e93<\/h4>\n<\/p>\n<p><p>ctypes\u5e93\u662fPython\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u63d0\u4f9b\u4e86\u4e0eC\u8bed\u8a00\u5e93\u8fdb\u884c\u4ea4\u4e92\u7684\u529f\u80fd\u3002\u53ef\u4ee5\u4f7f\u7528ctypes\u5e93\u76f4\u63a5\u8c03\u7528Windows API\u6765\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import ctypes<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>ctypes.windll.shell32.ShellExecuteW(None, &#39;open&#39;, &#39;calc.exe&#39;, None, None, 1)<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>ctypes.windll.shell32.ShellExecuteW(None, &#39;open&#39;, &#39;notepad.exe&#39;, None, None, 1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2 \u4f7f\u7528psutil\u5e93<\/h4>\n<\/p>\n<p><p>psutil\u5e93\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u8fdb\u7a0b\u7ba1\u7406\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u6765\u83b7\u53d6\u7cfb\u7edf\u4fe1\u606f\u548c\u7ba1\u7406\u8fdb\u7a0b\u3002\u53ef\u4ee5\u4f7f\u7528psutil\u5e93\u6765\u542f\u52a8\u548c\u7ba1\u7406\u5b50\u8fdb\u7a0b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import psutil<\/p>\n<h2><strong>\u6253\u5f00\u8ba1\u7b97\u5668<\/strong><\/h2>\n<p>calc_process = psutil.Popen([&#39;calc.exe&#39;])<\/p>\n<h2><strong>\u6253\u5f00\u8bb0\u4e8b\u672c<\/strong><\/h2>\n<p>notepad_process = psutil.Popen([&#39;notepad.exe&#39;])<\/p>\n<h2><strong>\u7b49\u5f85\u8ba1\u7b97\u5668\u8fdb\u7a0b\u7ed3\u675f<\/strong><\/h2>\n<p>calc_process.wait()<\/p>\n<h2><strong>\u7b49\u5f85\u8bb0\u4e8b\u672c\u8fdb\u7a0b\u7ed3\u675f<\/strong><\/h2>\n<p>notepad_process.wait()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>psutil\u5e93\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u8fdb\u7a0b\u7ba1\u7406\u529f\u80fd\uff0c\u5982\u83b7\u53d6\u8fdb\u7a0bCPU\u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u7b49\uff0c\u975e\u5e38\u9002\u5408\u9700\u8981\u8fdb\u884c\u7cfb\u7edf\u76d1\u63a7\u548c\u7ba1\u7406\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u7684\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ecos\u6a21\u5757\u3001subprocess\u6a21\u5757\u3001pywin32\u5e93\u4ee5\u53ca\u5176\u4ed6\u9ad8\u7ea7\u65b9\u6cd5\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u9002\u7528\u7684\u573a\u666f\u548c\u4f18\u52bf\uff0c\u8bfb\u8005\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002os\u6a21\u5757\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u7cfb\u7edf\u547d\u4ee4\u8c03\u7528\u529f\u80fd\uff0csubprocess\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u7684\u8fdb\u7a0b\u7ba1\u7406\u529f\u80fd\uff0cpywin32\u5e93\u63d0\u4f9b\u4e86\u5bf9Windows\u7cfb\u7edfAPI\u7684\u8bbf\u95ee\u80fd\u529b\uff0c\u5176\u4ed6\u9ad8\u7ea7\u65b9\u6cd5\u5982ctypes\u5e93\u548cpsutil\u5e93\u5219\u63d0\u4f9b\u4e86\u66f4\u5e95\u5c42\u548c\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u5b9e\u9645\u4ee3\u7801\u793a\u4f8b\uff0c\u8bfb\u8005\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u8bfb\u8005\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528Python\u8fdb\u884c\u7cfb\u7edf\u64cd\u4f5c\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8fd0\u884c\u7cfb\u7edf\u547d\u4ee4\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528<code>subprocess<\/code>\u6a21\u5757\u6765\u8fd0\u884c\u7cfb\u7edf\u547d\u4ee4\u3002\u901a\u8fc7<code>subprocess.run()<\/code>\uff0c\u60a8\u80fd\u591f\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\nsubprocess.run([&#39;your_command_here&#39;])\n<\/code><\/pre>\n<p>\u786e\u4fdd\u5c06<code>your_command_here<\/code>\u66ff\u6362\u4e3a\u60a8\u60f3\u8981\u6267\u884c\u7684\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u6253\u5f00\u7684\u7a0b\u5e8f\u7684\u8f93\u51fa\uff1f<\/strong><br \/>\u4f7f\u7528<code>subprocess<\/code>\u6a21\u5757\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>stdout<\/code>\u548c<code>stderr<\/code>\u53c2\u6570\u6765\u6355\u83b7\u7a0b\u5e8f\u7684\u8f93\u51fa\u548c\u9519\u8bef\u4fe1\u606f\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">result = subprocess.run([&#39;your_command_here&#39;], capture_output=True, text=True)\nprint(result.stdout)  # \u8f93\u51fa\u7a0b\u5e8f\u7684\u6807\u51c6\u8f93\u51fa\nprint(result.stderr)  # \u8f93\u51fa\u7a0b\u5e8f\u7684\u9519\u8bef\u4fe1\u606f\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u8ba9\u60a8\u80fd\u591f\u5728Python\u4e2d\u76f4\u63a5\u5904\u7406\u548c\u5206\u6790\u7a0b\u5e8f\u7684\u8f93\u51fa\u3002<\/p>\n<p><strong>Python\u80fd\u5426\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6253\u5f00\u7a0b\u5e8f\uff1f<\/strong><br \/>Python\u7684<code>subprocess<\/code>\u6a21\u5757\u662f\u8de8\u5e73\u53f0\u7684\uff0c\u80fd\u591f\u5728Windows\u3001macOS\u548cLinux\u7b49\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6253\u5f00\u7a0b\u5e8f\u3002\u53ea\u9700\u786e\u4fdd\u60a8\u4f7f\u7528\u7684\u547d\u4ee4\u5728\u76ee\u6807\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u53ef\u7528\u3002\u4f8b\u5982\uff0c\u5728Windows\u4e0a\u60a8\u53ef\u80fd\u4f1a\u4f7f\u7528<code>notepad.exe<\/code>\uff0c\u800c\u5728Linux\u4e0a\u5219\u53ef\u80fd\u4f7f\u7528<code>gedit<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u6253\u5f00\u7cfb\u7edf\u7a0b\u5e8f\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528os\u6a21\u5757\u3001subprocess\u6a21\u5757\u4ee5\u53ca\u5176\u4ed6\u9ad8\u7ea7\u5e93\uff0c\u5982pywin [&hellip;]","protected":false},"author":3,"featured_media":1184781,"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\/1184774"}],"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=1184774"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1184774\/revisions"}],"predecessor-version":[{"id":1184784,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1184774\/revisions\/1184784"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1184781"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1184774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1184774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1184774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}