{"id":1080631,"date":"2025-01-08T12:31:55","date_gmt":"2025-01-08T04:31:55","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1080631.html"},"modified":"2025-01-08T12:31:59","modified_gmt":"2025-01-08T04:31:59","slug":"%e5%a6%82%e4%bd%95%e5%90%8c%e6%97%b6%e6%89%a7%e8%a1%8c%e4%b8%a4%e4%b8%aapython%e8%84%9a%e6%9c%ac-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1080631.html","title":{"rendered":"\u5982\u4f55\u540c\u65f6\u6267\u884c\u4e24\u4e2apython\u811a\u672c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183049\/288476b0-d742-4c44-8ade-3c4147e393aa.webp\" alt=\"\u5982\u4f55\u540c\u65f6\u6267\u884c\u4e24\u4e2apython\u811a\u672c\" \/><\/p>\n<p><p> <strong>\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u6709\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u591a\u7ebf\u7a0b\u3001\u4f7f\u7528\u591a\u8fdb\u7a0b\u3001\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\u3001\u4f7f\u7528Python\u7684subprocess\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528subprocess\u6a21\u5757\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u4e14\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u542f\u52a8\u548c\u7ba1\u7406\u5b50\u8fdb\u7a0b\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528subprocess\u6a21\u5757\u6765\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528subprocess\u6a21\u5757<\/h3>\n<\/p>\n<p><p>Python\u7684subprocess\u6a21\u5757\u5141\u8bb8\u4f60\u751f\u6210\u65b0\u7684\u8fdb\u7a0b\u3001\u8fde\u63a5\u5230\u4ed6\u4eec\u7684\u8f93\u5165\/\u8f93\u51fa\/\u9519\u8bef\u7ba1\u9053\uff0c\u5e76\u83b7\u53d6\u5b83\u4eec\u7684\u8fd4\u56de\u7801\u3002\u5b83\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u548c\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u542f\u52a8\u548c\u4e0e\u5b50\u8fdb\u7a0b\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528subprocess\u6a21\u5757\u4e2d\u7684<code>Popen<\/code>\u51fd\u6570\u6765\u540c\u65f6\u542f\u52a8\u4e24\u4e2aPython\u811a\u672c\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e00\u4e2a\u811a\u672c<\/strong><\/h2>\n<p>process1 = subprocess.Popen([&#39;python&#39;, &#39;script1.py&#39;])<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e8c\u4e2a\u811a\u672c<\/strong><\/h2>\n<p>process2 = subprocess.Popen([&#39;python&#39;, &#39;script2.py&#39;])<\/p>\n<h2><strong>\u7b49\u5f85\u4e24\u4e2a\u811a\u672c\u90fd\u5b8c\u6210<\/strong><\/h2>\n<p>process1.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t()<\/p>\n<p>process2.wait()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>subprocess.Popen<\/code>\u6765\u542f\u52a8\u4e24\u4e2a\u811a\u672c\u3002<code>Popen<\/code>\u51fd\u6570\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u56e0\u6b64\u4e24\u4e2a\u811a\u672c\u4f1a\u540c\u65f6\u8fd0\u884c\u3002\u6211\u4eec\u4f7f\u7528<code>wait<\/code>\u65b9\u6cd5\u6765\u7b49\u5f85\u8fd9\u4e24\u4e2a\u811a\u672c\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h4>2. \u6355\u83b7\u8f93\u51fa<\/h4>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6355\u83b7\u5e76\u5904\u7406\u5b50\u8fdb\u7a0b\u7684\u8f93\u51fa\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>Popen<\/code>\u7684<code>stdout<\/code>\u548c<code>stderr<\/code>\u53c2\u6570\u6765\u6355\u83b7\u8f93\u51fa\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import subprocess<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e00\u4e2a\u811a\u672c\u5e76\u6355\u83b7\u8f93\u51fa<\/strong><\/h2>\n<p>process1 = subprocess.Popen([&#39;python&#39;, &#39;script1.py&#39;], stdout=subprocess.PIPE, stderr=subprocess.PIPE)<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e8c\u4e2a\u811a\u672c\u5e76\u6355\u83b7\u8f93\u51fa<\/strong><\/h2>\n<p>process2 = subprocess.Popen([&#39;python&#39;, &#39;script2.py&#39;], stdout=subprocess.PIPE, stderr=subprocess.PIPE)<\/p>\n<h2><strong>\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u811a\u672c\u7684\u8f93\u51fa<\/strong><\/h2>\n<p>output1, error1 = process1.communicate()<\/p>\n<h2><strong>\u8bfb\u53d6\u7b2c\u4e8c\u4e2a\u811a\u672c\u7684\u8f93\u51fa<\/strong><\/h2>\n<p>output2, error2 = process2.communicate()<\/p>\n<p>print(&#39;Script 1 output:&#39;, output1.decode())<\/p>\n<p>print(&#39;Script 2 output:&#39;, output2.decode())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528<code>stdout=subprocess.PIPE<\/code>\u548c<code>stderr=subprocess.PIPE<\/code>\u53c2\u6570\u6765\u6355\u83b7\u5b50\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u3002\u6211\u4eec\u4f7f\u7528<code>communicate<\/code>\u65b9\u6cd5\u6765\u8bfb\u53d6\u8fd9\u4e9b\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b<\/h3>\n<\/p>\n<p><p>\u591a\u7ebf\u7a0b\u662f\u53e6\u4e00\u79cd\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u7684\u65b9\u6cd5\u3002\u867d\u7136Python\u7684GIL\uff08\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff09\u4f1a\u9650\u5236CPU\u7ed1\u5b9a\u7684\u591a\u7ebf\u7a0b\u7684\u6027\u80fd\uff0c\u4f46\u5bf9\u4e8eI\/O\u7ed1\u5b9a\u7684\u4efb\u52a1\uff0c\u591a\u7ebf\u7a0b\u4ecd\u7136\u662f\u4e00\u4e2a\u6709\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>threading<\/code>\u6a21\u5757\u6765\u542f\u52a8\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8fd0\u884c\u4e00\u4e2aPython\u811a\u672c\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import os<\/p>\n<p>def run_script(script_name):<\/p>\n<p>    os.system(f&#39;python {script_name}&#39;)<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e00\u4e2a\u7ebf\u7a0b<\/strong><\/h2>\n<p>thread1 = threading.Thread(target=run_script, args=(&#39;script1.py&#39;,))<\/p>\n<p>thread1.start()<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b<\/strong><\/h2>\n<p>thread2 = threading.Thread(target=run_script, args=(&#39;script2.py&#39;,))<\/p>\n<p>thread2.start()<\/p>\n<h2><strong>\u7b49\u5f85\u4e24\u4e2a\u7ebf\u7a0b\u90fd\u5b8c\u6210<\/strong><\/h2>\n<p>thread1.join()<\/p>\n<p>thread2.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a<code>run_script<\/code>\u51fd\u6570\u6765\u8fd0\u884c\u4e00\u4e2aPython\u811a\u672c\uff0c\u5e76\u4f7f\u7528<code>threading.Thread<\/code>\u6765\u542f\u52a8\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8fd0\u884c\u4e00\u4e2a\u811a\u672c\u3002\u6211\u4eec\u4f7f\u7528<code>start<\/code>\u65b9\u6cd5\u6765\u542f\u52a8\u7ebf\u7a0b\uff0c\u4f7f\u7528<code>join<\/code>\u65b9\u6cd5\u6765\u7b49\u5f85\u7ebf\u7a0b\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u591a\u8fdb\u7a0b<\/h3>\n<\/p>\n<p><p>\u591a\u8fdb\u7a0b\u662f\u53e6\u4e00\u79cd\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u7684\u65b9\u6cd5\uff0c\u7279\u522b\u9002\u7528\u4e8eCPU\u7ed1\u5b9a\u7684\u4efb\u52a1\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u7684GIL\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>multiprocessing<\/code>\u6a21\u5757\u6765\u542f\u52a8\u4e24\u4e2a\u8fdb\u7a0b\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u8fd0\u884c\u4e00\u4e2aPython\u811a\u672c\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import multiprocessing<\/p>\n<p>import os<\/p>\n<p>def run_script(script_name):<\/p>\n<p>    os.system(f&#39;python {script_name}&#39;)<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e00\u4e2a\u8fdb\u7a0b<\/strong><\/h2>\n<p>process1 = multiprocessing.Process(target=run_script, args=(&#39;script1.py&#39;,))<\/p>\n<p>process1.start()<\/p>\n<h2><strong>\u542f\u52a8\u7b2c\u4e8c\u4e2a\u8fdb\u7a0b<\/strong><\/h2>\n<p>process2 = multiprocessing.Process(target=run_script, args=(&#39;script2.py&#39;,))<\/p>\n<p>process2.start()<\/p>\n<h2><strong>\u7b49\u5f85\u4e24\u4e2a\u8fdb\u7a0b\u90fd\u5b8c\u6210<\/strong><\/h2>\n<p>process1.join()<\/p>\n<p>process2.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a<code>run_script<\/code>\u51fd\u6570\u6765\u8fd0\u884c\u4e00\u4e2aPython\u811a\u672c\uff0c\u5e76\u4f7f\u7528<code>multiprocessing.Process<\/code>\u6765\u542f\u52a8\u4e24\u4e2a\u8fdb\u7a0b\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u8fd0\u884c\u4e00\u4e2a\u811a\u672c\u3002\u6211\u4eec\u4f7f\u7528<code>start<\/code>\u65b9\u6cd5\u6765\u542f\u52a8\u8fdb\u7a0b\uff0c\u4f7f\u7528<code>join<\/code>\u65b9\u6cd5\u6765\u7b49\u5f85\u8fdb\u7a0b\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f<\/h3>\n<\/p>\n<p><p>\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\uff08\u5982cron\u3001Task Scheduler\uff09\u6765\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u3002\u8fd9\u79cd\u65b9\u6cd5\u901a\u5e38\u7528\u4e8e\u5728\u7279\u5b9a\u65f6\u95f4\u6216\u95f4\u9694\u81ea\u52a8\u8fd0\u884c\u811a\u672c\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528cron\uff08\u5728Linux\u4e0a\uff09<\/h4>\n<\/p>\n<p><p>cron\u662f\u4e00\u4e2aLinux\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u7528\u6765\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u6216\u95f4\u9694\u8fd0\u884c\u4efb\u52a1\u3002\u4f60\u53ef\u4ee5\u7f16\u8f91crontab\u6587\u4ef6\u6765\u8c03\u5ea6\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6253\u5f00crontab\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">crontab -e<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6dfb\u52a0\u4e24\u884c\u6765\u8c03\u5ea6\u4e24\u4e2aPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">* * * * * python \/path\/to\/script1.py<\/p>\n<p>* * * * * python \/path\/to\/script2.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u5728\u6bcf\u4e00\u5206\u949f\u540c\u65f6\u8fd0\u884c\u4e24\u4e2a\u811a\u672c\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8c03\u6574\u65f6\u95f4\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528Task Scheduler\uff08\u5728Windows\u4e0a\uff09<\/h4>\n<\/p>\n<p><p>Task Scheduler\u662f\u4e00\u4e2aWindows\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u7528\u6765\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u6216\u95f4\u9694\u8fd0\u884c\u4efb\u52a1\u3002\u4f60\u53ef\u4ee5\u521b\u5efa\u4e24\u4e2a\u4efb\u52a1\u6765\u8c03\u5ea6\u4e24\u4e2aPython\u811a\u672c\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6253\u5f00Task Scheduler\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u70b9\u51fb\u201c\u5f00\u59cb\u201d\u83dc\u5355\uff0c\u641c\u7d22\u201cTask Scheduler\u201d\u5e76\u6253\u5f00\u5b83\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\u7684\u201c\u64cd\u4f5c\u201d\u7a97\u683c\u4e2d\uff0c\u70b9\u51fb\u201c\u521b\u5efa\u57fa\u672c\u4efb\u52a1\u201d\u3002<\/li>\n<li>\u6309\u7167\u5411\u5bfc\u521b\u5efa\u4e00\u4e2a\u4efb\u52a1\uff0c\u8bbe\u7f6e\u89e6\u53d1\u5668\u548c\u64cd\u4f5c\u3002\u64cd\u4f5c\u5e94\u8be5\u662f\u8fd0\u884cPython\u811a\u672c\uff0c\u4f8b\u5982\uff1a<code>python C:\\path\\to\\script1.py<\/code>\u3002<\/li>\n<li>\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u4e3a\u7b2c\u4e8c\u4e2aPython\u811a\u672c\u521b\u5efa\u53e6\u4e00\u4e2a\u4efb\u52a1\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528subprocess\u6a21\u5757<\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u7ba1\u7406\u548c\u6355\u83b7\u5b50\u8fdb\u7a0b\u8f93\u51fa\u7684\u60c5\u51b5\u3002<\/li>\n<li><strong>\u4f7f\u7528\u591a\u7ebf\u7a0b<\/strong>\uff1a\u9002\u7528\u4e8eI\/O\u7ed1\u5b9a\u7684\u4efb\u52a1\u3002<\/li>\n<li><strong>\u4f7f\u7528\u591a\u8fdb\u7a0b<\/strong>\uff1a\u9002\u7528\u4e8eCPU\u7ed1\u5b9a\u7684\u4efb\u52a1\u3002<\/li>\n<li><strong>\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f<\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u5728\u7279\u5b9a\u65f6\u95f4\u6216\u95f4\u9694\u81ea\u52a8\u8fd0\u884c\u811a\u672c\u7684\u60c5\u51b5\u3002<\/li>\n<\/ol>\n<p><p>\u9009\u62e9\u9002\u5408\u4f60\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u5e76\u6839\u636e\u793a\u4f8b\u4ee3\u7801\u8fdb\u884c\u5b9e\u73b0\u3002\u65e0\u8bba\u662fsubprocess\u3001\u591a\u7ebf\u7a0b\u3001\u591a\u8fdb\u7a0b\u8fd8\u662f\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u70b9\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9ad8\u6548\u5730\u540c\u65f6\u6267\u884c\u591a\u4e2aPython\u811a\u672c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u4e0d\u540c\u7684\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4e24\u4e2aPython\u811a\u672c\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u4e24\u4e2a\u4e0d\u540c\u7684\u7ec8\u7aef\u7a97\u53e3\u6765\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u3002\u5728\u6bcf\u4e2a\u7ec8\u7aef\u4e2d\uff0c\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u5e76\u4f7f\u7528\u547d\u4ee4<code>python script1.py<\/code>\u548c<code>python script2.py<\/code>\u5206\u522b\u8fd0\u884c\u6bcf\u4e2a\u811a\u672c\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8eLinux\u3001MacOS\u548cWindows\u7b49\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728\u4e00\u4e2aPython\u811a\u672c\u4e2d\u8c03\u7528\u53e6\u4e00\u4e2a\u811a\u672c\uff1f<\/strong><br \/>\u786e\u5b9e\u53ef\u4ee5\u3002\u5728\u4e00\u4e2aPython\u811a\u672c\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>import<\/code>\u8bed\u53e5\u5f15\u5165\u53e6\u4e00\u4e2aPython\u811a\u672c\u7684\u529f\u80fd\u3002\u901a\u8fc7\u5b9a\u4e49\u51fd\u6570\u5e76\u8c03\u7528\u5b83\u4eec\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e24\u4e2a\u811a\u672c\u95f4\u7684\u4ea4\u4e92\u3002\u5982\u679c\u9700\u8981\u5e76\u884c\u6267\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6a21\u5757\uff0c\u4f8b\u5982<code>threading<\/code>\u6216<code>multiprocessing<\/code>\u3002<\/p>\n<p><strong>\u4f7f\u7528\u4ec0\u4e48\u5de5\u5177\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u540c\u65f6\u8fd0\u884c\u591a\u4e2aPython\u811a\u672c\uff1f<\/strong><br \/>\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u50cf<code>tmux<\/code>\u6216<code>screen<\/code>\u8fd9\u6837\u7684\u7ec8\u7aef\u590d\u7528\u5de5\u5177\uff0c\u8fd9\u4e9b\u5de5\u5177\u5141\u8bb8\u5728\u4e00\u4e2a\u7a97\u53e3\u4e2d\u7ba1\u7406\u591a\u4e2a\u4f1a\u8bdd\uff0c\u4fbf\u4e8e\u540c\u65f6\u8fd0\u884c\u591a\u4e2aPython\u811a\u672c\u3002\u6b64\u5916\uff0c\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982PyCharm\u6216VS Code\u4e5f\u63d0\u4f9b\u4e86\u5728\u4e0d\u540c\u7684\u8fd0\u884c\u914d\u7f6e\u4e2d\u5e76\u884c\u6267\u884c\u591a\u4e2a\u811a\u672c\u7684\u9009\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u540c\u65f6\u6267\u884c\u4e24\u4e2aPython\u811a\u672c\u6709\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u591a\u7ebf\u7a0b\u3001\u4f7f\u7528\u591a\u8fdb\u7a0b\u3001\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u4efb\u52a1\u8c03\u5ea6\u7a0b\u5e8f\u3001\u4f7f\u7528Python\u7684 [&hellip;]","protected":false},"author":3,"featured_media":1080641,"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\/1080631"}],"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=1080631"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1080631\/revisions"}],"predecessor-version":[{"id":1080643,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1080631\/revisions\/1080643"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1080641"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1080631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1080631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1080631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}