我想让我的python脚本在后台运行,并且需要在启动时启动。
我引用this链接将python脚本作为窗口服务。但是,当我启动窗口服务时,它显示错误:
The service is not responding to the control function.
我的python脚本:
import schedule
import time
import datetime
#datetime.datetime.now().strftime("%H:%M")
def job():
print("Scheduling is Working...")
createfile()
def createfile():
company = "HELLO USER"
with open('company.txt', 'w+') as f:
f.write(str(company))
print("File Created on:",time.ctime(time.time()))
f.close()
return True
# schedule.every(10).minutes.do(job)
# schedule.every().hour.do(job)
#schedule.every().day.at("11.40").do(job)
schedule.every(1).minutes.do(job)
while 1:
schedule.run_pending()
time.sleep(1)
答案 0 :(得分:0)