【发布时间】:2023-06-23 05:13:01
【问题描述】:
我希望以后每天早上 8 点自动运行一个 python 文件。我尝试在 Windows 中使用schedule 中指出的库second answer here。
import schedule
import time
def query_fun(t):
print('Do a bunch of things')
print("I'm working...", t)
df.to_csv('C:/Documents/Query_output.csv', encoding='utf-8')
schedule.every().day.at("08:00").do(query_fun, 'It is 08:00')
while True:
schedule.run_pending()
time.sleep(60) # wait one minute
但是早上 8 点来了又走了,csv 文件还没有更新,而且看起来脚本不像我想要的那样运行。
编辑:基于this,我使用pythonw.exe在命令行中运行脚本:C:\Program Files\Python3.7>pythonw.exe daily_query.py,但脚本没有按预期运行。
【问题讨论】: