{"id":1048071,"date":"2024-12-31T13:47:52","date_gmt":"2024-12-31T05:47:52","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1048071.html"},"modified":"2024-12-31T13:47:54","modified_gmt":"2024-12-31T05:47:54","slug":"%e5%a6%82%e4%bd%95%e5%b0%86python%e4%bb%a3%e7%a0%81%e5%ae%9a%e6%97%b6%e8%87%aa%e5%8a%a8%e6%89%a7%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1048071.html","title":{"rendered":"\u5982\u4f55\u5c06python\u4ee3\u7801\u5b9a\u65f6\u81ea\u52a8\u6267\u884c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/26b912e1-7720-4cee-9648-9fd864c6865f.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u5c06python\u4ee3\u7801\u5b9a\u65f6\u81ea\u52a8\u6267\u884c\" \/><\/p>\n<p><p> <strong>\u8981\u5c06Python\u4ee3\u7801\u5b9a\u65f6\u81ea\u52a8\u6267\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1\u3001\u4f7f\u7528Python\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u8c03\u5ea6\u5e93\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1<\/strong>\u662f\u6700\u5e38\u89c1\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1\u53ef\u4ee5\u975e\u5e38\u7075\u6d3b\u5730\u5b89\u6392\u4efb\u52a1\u7684\u6267\u884c\u65f6\u95f4\u3002\u4ee5Windows\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4f8b\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u201c\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u201d\u6765\u8bbe\u7f6ePython\u811a\u672c\u7684\u5b9a\u65f6\u6267\u884c\u3002\u9996\u5148\uff0c\u6253\u5f00\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\uff0c\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u4efb\u52a1\uff0c\u8bbe\u7f6e\u89e6\u53d1\u5668\u548c\u52a8\u4f5c\uff0c\u5728\u52a8\u4f5c\u4e2d\u9009\u62e9Python\u89e3\u91ca\u5668\u5e76\u6307\u5b9a\u811a\u672c\u8def\u5f84\u5373\u53ef\u3002\u8fd9\u6837\uff0cPython\u811a\u672c\u5c31\u4f1a\u6309\u7167\u8bbe\u5b9a\u7684\u65f6\u95f4\u81ea\u52a8\u6267\u884c\u3002<\/p>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1<\/h3>\n<\/p>\n<p><p>\u5728Windows\u548cLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u90fd\u6709\u5185\u7f6e\u7684\u8ba1\u5212\u4efb\u52a1\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u7528\u6765\u5b9a\u65f6\u6267\u884cPython\u811a\u672c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001Windows\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f<\/h4>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u6765\u8bbe\u7f6ePython\u811a\u672c\u7684\u5b9a\u65f6\u4efb\u52a1\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\uff1a\u6309Win+R\u952e\uff0c\u8f93\u5165\u201ctaskschd.msc\u201d\u5e76\u56de\u8f66\u3002<\/li>\n<li>\u521b\u5efa\u57fa\u672c\u4efb\u52a1\uff1a\u5728\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u4e2d\uff0c\u70b9\u51fb\u201c\u521b\u5efa\u57fa\u672c\u4efb\u52a1\u201d\u3002<\/li>\n<li>\u8bbe\u7f6e\u4efb\u52a1\u540d\u79f0\u548c\u63cf\u8ff0\uff1a\u8f93\u5165\u4efb\u52a1\u540d\u79f0\u548c\u63cf\u8ff0\u540e\uff0c\u70b9\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u8bbe\u7f6e\u89e6\u53d1\u5668\uff1a\u9009\u62e9\u4efb\u52a1\u7684\u89e6\u53d1\u65f6\u95f4\uff0c\u53ef\u4ee5\u662f\u6bcf\u5929\u3001\u6bcf\u5468\u3001\u6bcf\u6708\u7b49\uff0c\u70b9\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u8bbe\u7f6e\u65f6\u95f4\u548c\u9891\u7387\uff1a\u6839\u636e\u9700\u8981\u8bbe\u7f6e\u5177\u4f53\u65f6\u95f4\u548c\u9891\u7387\uff0c\u70b9\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u8bbe\u7f6e\u64cd\u4f5c\uff1a\u9009\u62e9\u201c\u542f\u52a8\u7a0b\u5e8f\u201d\uff0c\u70b9\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u9009\u62e9\u7a0b\u5e8f\u548c\u811a\u672c\uff1a\u5728\u201c\u7a0b\u5e8f\/\u811a\u672c\u201d\u6846\u4e2d\u8f93\u5165Python\u89e3\u91ca\u5668\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Python39\\python.exe\uff09\uff0c\u5728\u201c\u6dfb\u52a0\u53c2\u6570\u201d\u6846\u4e2d\u8f93\u5165Python\u811a\u672c\u7684\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Scripts\\myscript.py\uff09\uff0c\u70b9\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u786e\u8ba4\u8bbe\u7f6e\uff1a\u68c0\u67e5\u6240\u6709\u8bbe\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u70b9\u51fb\u201c\u5b8c\u6210\u201d\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001Linux\u7684cron<\/h4>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528cron\u6765\u8bbe\u7f6ePython\u811a\u672c\u7684\u5b9a\u65f6\u4efb\u52a1\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u7f16\u8f91crontab\u6587\u4ef6\uff1a\u8f93\u5165<code>crontab -e<\/code>\u547d\u4ee4\u6253\u5f00crontab\u6587\u4ef6\u3002<\/li>\n<li>\u6dfb\u52a0\u5b9a\u65f6\u4efb\u52a1\uff1a\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u884c\u5b9a\u65f6\u4efb\u52a1\uff0c\u4f8b\u5982\uff0c\u6bcf\u5929\u51cc\u66681\u70b9\u6267\u884c\u811a\u672c\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\n<pre><code>0 1 * * * \/usr\/bin\/python3 \/path\/to\/your_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8fd9\u884c\u547d\u4ee4\u7684\u542b\u4e49\u662f\u6bcf\u5929\u51cc\u66681\u70b9\u6267\u884c<code>\/path\/to\/your_script.py<\/code>\u811a\u672c\u3002<\/li>\n<\/p>\n<li>\u4fdd\u5b58\u5e76\u9000\u51fa\uff1a\u4fdd\u5b58crontab\u6587\u4ef6\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Python\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93<\/h3>\n<\/p>\n<p><p>Python\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93\uff0c\u5982<code>time<\/code>\u3001<code>sched<\/code>\uff0c\u4e5f\u53ef\u4ee5\u7528\u6765\u5b9a\u65f6\u6267\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528time\u6a21\u5757<\/h4>\n<\/p>\n<p><p><code>time<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u57fa\u672c\u7684\u65f6\u95f4\u76f8\u5173\u529f\u80fd\uff0c\u53ef\u4ee5\u4f7f\u7528<code>time.sleep()<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\u5b9a\u65f6\u6267\u884c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>def my_task():<\/p>\n<p>    print(&quot;Task executed&quot;)<\/p>\n<p>while True:<\/p>\n<p>    my_task()<\/p>\n<p>    time.sleep(3600)  # \u6bcf\u5c0f\u65f6\u6267\u884c\u4e00\u6b21<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528sched\u6a21\u5757<\/h4>\n<\/p>\n<p><p><code>sched<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u8c03\u5ea6\u529f\u80fd\uff0c\u53ef\u4ee5\u7528\u6765\u5b9a\u65f6\u6267\u884c\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sched<\/p>\n<p>import time<\/p>\n<p>def my_task():<\/p>\n<p>    print(&quot;Task executed&quot;)<\/p>\n<p>scheduler = sched.scheduler(time.time, time.sleep)<\/p>\n<p>def schedule_task():<\/p>\n<p>    scheduler.enter(3600, 1, schedule_task)  # \u6bcf\u5c0f\u65f6\u6267\u884c\u4e00\u6b21<\/p>\n<p>    my_task()<\/p>\n<p>scheduler.enter(0, 1, schedule_task)<\/p>\n<p>scheduler.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u8c03\u5ea6\u5e93<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u8c03\u5ea6\u5e93\uff0c\u5982<code>APScheduler<\/code>\u3001<code>schedule<\/code>\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528APScheduler<\/h4>\n<\/p>\n<p><p><code>APScheduler<\/code>\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u8c03\u5ea6\u5e93\uff0c\u53ef\u4ee5\u975e\u5e38\u7075\u6d3b\u5730\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from apscheduler.schedulers.blocking import BlockingScheduler<\/p>\n<p>def my_task():<\/p>\n<p>    print(&quot;Task executed&quot;)<\/p>\n<p>scheduler = BlockingScheduler()<\/p>\n<p>scheduler.add_job(my_task, &#39;interval&#39;, hours=1)  # \u6bcf\u5c0f\u65f6\u6267\u884c\u4e00\u6b21<\/p>\n<p>scheduler.start()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528schedule<\/h4>\n<\/p>\n<p><p><code>schedule<\/code>\u662f\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u8c03\u5ea6\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import schedule<\/p>\n<p>import time<\/p>\n<p>def my_task():<\/p>\n<p>    print(&quot;Task executed&quot;)<\/p>\n<p>schedule.every().hour.do(my_task)  # \u6bcf\u5c0f\u65f6\u6267\u884c\u4e00\u6b21<\/p>\n<p>while True:<\/p>\n<p>    schedule.run_pending()<\/p>\n<p>    time.sleep(1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u4e91\u670d\u52a1\u8fdb\u884c\u8c03\u5ea6<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u5728\u4e91\u73af\u5883\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e91\u670d\u52a1\u63d0\u4f9b\u7684\u5b9a\u65f6\u8c03\u5ea6\u529f\u80fd\uff0c\u4f8b\u5982AWS Lambda\u3001Google Cloud Functions\u3001Azure Functions\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528AWS Lambda<\/h4>\n<\/p>\n<p><p>AWS Lambda\u662f\u4e00\u79cd\u65e0\u670d\u52a1\u5668\u8ba1\u7b97\u670d\u52a1\uff0c\u53ef\u4ee5\u81ea\u52a8\u6267\u884c\u4ee3\u7801\u3002\u53ef\u4ee5\u4f7f\u7528Amazon CloudWatch Events\u6765\u89e6\u53d1Lambda\u51fd\u6570\u3002<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efaLambda\u51fd\u6570\uff1a\u5728AWS\u7ba1\u7406\u63a7\u5236\u53f0\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Lambda\u51fd\u6570\u3002<\/li>\n<li>\u914d\u7f6e\u89e6\u53d1\u5668\uff1a\u5728Lambda\u51fd\u6570\u7684\u914d\u7f6e\u9875\u9762\uff0c\u6dfb\u52a0\u4e00\u4e2aCloudWatch Events\u89e6\u53d1\u5668\uff0c\u8bbe\u7f6e\u89e6\u53d1\u89c4\u5219\u3002<\/li>\n<li>\u90e8\u7f72\u4ee3\u7801\uff1a\u5c06Python\u4ee3\u7801\u4e0a\u4f20\u5230Lambda\u51fd\u6570\u4e2d\u3002<\/li>\n<\/ol>\n<p><h4>2\u3001\u4f7f\u7528Google Cloud Functions<\/h4>\n<\/p>\n<p><p>Google Cloud Functions\u662f\u4e00\u79cd\u4e8b\u4ef6\u9a71\u52a8\u7684\u65e0\u670d\u52a1\u5668\u8ba1\u7b97\u670d\u52a1\uff0c\u53ef\u4ee5\u81ea\u52a8\u6267\u884c\u4ee3\u7801\u3002\u53ef\u4ee5\u4f7f\u7528Google Cloud Scheduler\u6765\u89e6\u53d1Cloud Functions\u3002<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efaCloud Function\uff1a\u5728Google Cloud Console\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Cloud Function\u3002<\/li>\n<li>\u914d\u7f6e\u89e6\u53d1\u5668\uff1a\u5728Cloud Function\u7684\u914d\u7f6e\u9875\u9762\uff0c\u6dfb\u52a0\u4e00\u4e2aCloud Scheduler\u89e6\u53d1\u5668\uff0c\u8bbe\u7f6e\u89e6\u53d1\u89c4\u5219\u3002<\/li>\n<li>\u90e8\u7f72\u4ee3\u7801\uff1a\u5c06Python\u4ee3\u7801\u4e0a\u4f20\u5230Cloud Function\u4e2d\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4f7f\u7528Azure Functions<\/h4>\n<\/p>\n<p><p>Azure Functions\u662f\u4e00\u79cd\u4e8b\u4ef6\u9a71\u52a8\u7684\u65e0\u670d\u52a1\u5668\u8ba1\u7b97\u670d\u52a1\uff0c\u53ef\u4ee5\u81ea\u52a8\u6267\u884c\u4ee3\u7801\u3002\u53ef\u4ee5\u4f7f\u7528Azure Logic Apps\u6216Azure Timer Trigger\u6765\u89e6\u53d1Functions\u3002<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efaAzure Function\uff1a\u5728Azure\u95e8\u6237\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Azure Function\u3002<\/li>\n<li>\u914d\u7f6e\u89e6\u53d1\u5668\uff1a\u5728Function\u7684\u914d\u7f6e\u9875\u9762\uff0c\u6dfb\u52a0\u4e00\u4e2aTimer Trigger\u6216Logic Apps\u89e6\u53d1\u5668\uff0c\u8bbe\u7f6e\u89e6\u53d1\u89c4\u5219\u3002<\/li>\n<li>\u90e8\u7f72\u4ee3\u7801\uff1a\u5c06Python\u4ee3\u7801\u4e0a\u4f20\u5230Azure Function\u4e2d\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5c06Python\u4ee3\u7801\u5b9a\u65f6\u81ea\u52a8\u6267\u884c\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u9700\u6c42\u548c\u73af\u5883\u3002\u5bf9\u4e8e\u7b80\u5355\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1\uff1b\u5bf9\u4e8e\u9700\u8981\u66f4\u591a\u7075\u6d3b\u6027\u548c\u63a7\u5236\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93\u6216\u7b2c\u4e09\u65b9\u8c03\u5ea6\u5e93\uff1b\u5bf9\u4e8e\u4e91\u73af\u5883\u4e2d\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e91\u670d\u52a1\u63d0\u4f9b\u7684\u5b9a\u65f6\u8c03\u5ea6\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u9700\u8981\u786e\u4fddPython\u4ee3\u7801\u80fd\u591f\u6b63\u786e\u6267\u884c\uff0c\u5e76\u4e14\u5728\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\u65f6\u6ce8\u610f\u65f6\u95f4\u548c\u9891\u7387\u7684\u5408\u7406\u6027\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u8003\u8651\u9519\u8bef\u5904\u7406\u548c\u65e5\u5fd7\u8bb0\u5f55\uff0c\u4ee5\u4fbf\u5728\u4efb\u52a1\u6267\u884c\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\u65f6\u80fd\u591f\u53ca\u65f6\u53d1\u73b0\u548c\u89e3\u51b3\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u7f16\u5199\u5b9a\u65f6\u4efb\u52a1\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u7f16\u5199\u5b9a\u65f6\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>time<\/code>\u6a21\u5757\u914d\u5408\u5faa\u73af\u7ed3\u6784\uff0c\u901a\u8fc7<code>time.sleep()<\/code>\u51fd\u6570\u5b9e\u73b0\u5b9a\u65f6\u6267\u884c\u3002\u6b64\u5916\uff0cPython\u7684<code>schedule<\/code>\u5e93\u4e5f\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u8c03\u5ea6\u529f\u80fd\uff0c\u5141\u8bb8\u60a8\u8bbe\u7f6e\u5177\u4f53\u7684\u6267\u884c\u65f6\u95f4\u548c\u9891\u7387\uff0c\u4f7f\u7528\u8d77\u6765\u66f4\u52a0\u7075\u6d3b\u65b9\u4fbf\u3002<\/p>\n<p><strong>\u54ea\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u6211\u5b9e\u73b0Python\u4ee3\u7801\u7684\u5b9a\u65f6\u6267\u884c\uff1f<\/strong><br \/>\u9664\u4e86\u76f4\u63a5\u5728Python\u4e2d\u5b9e\u73b0\u5b9a\u65f6\u4efb\u52a1\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u5de5\u5177\u53ef\u4ee5\u8f85\u52a9\u60a8\u3002\u6bd4\u5982\uff0c<code>cron<\/code>\u662fLinux\u7cfb\u7edf\u4e2d\u975e\u5e38\u6d41\u884c\u7684\u5b9a\u65f6\u4efb\u52a1\u7ba1\u7406\u5de5\u5177\uff0c\u901a\u8fc7\u914d\u7f6e<code>crontab<\/code>\u6587\u4ef6\u53ef\u4ee5\u5b9a\u671f\u8fd0\u884cPython\u811a\u672c\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u6765\u5b89\u6392Python\u811a\u672c\u7684\u6267\u884c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u4e91\u73af\u5883\u4e2d\u5b9e\u73b0Python\u4ee3\u7801\u7684\u81ea\u52a8\u6267\u884c\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u5e0c\u671b\u5728\u4e91\u73af\u5883\u4e2d\u5b9e\u73b0Python\u4ee3\u7801\u7684\u81ea\u52a8\u6267\u884c\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5982AWS Lambda\u3001Google Cloud Functions\u7b49\u65e0\u670d\u52a1\u5668\u8ba1\u7b97\u670d\u52a1\u3002\u8fd9\u4e9b\u670d\u52a1\u5141\u8bb8\u60a8\u8bbe\u7f6e\u89e6\u53d1\u5668\uff0c\u4ee5\u4fbf\u5728\u7279\u5b9a\u65f6\u95f4\u6216\u4e8b\u4ef6\u53d1\u751f\u65f6\u81ea\u52a8\u8fd0\u884cPython\u4ee3\u7801\uff0c\u6781\u5927\u5730\u7b80\u5316\u4e86\u7ba1\u7406\u548c\u8fd0\u7ef4\u7684\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5c06Python\u4ee3\u7801\u5b9a\u65f6\u81ea\u52a8\u6267\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u8ba1\u5212\u4efb\u52a1\u3001\u4f7f\u7528Python\u5185\u7f6e\u7684\u8c03\u5ea6\u5e93\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1048082,"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\/1048071"}],"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=1048071"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1048071\/revisions"}],"predecessor-version":[{"id":1048091,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1048071\/revisions\/1048091"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1048082"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1048071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1048071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1048071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}