import time, os, sched
schedule = sched.scheduler(time.time, time.sleep) # 生成调度器
def command(cmd):
os.system(cmd) # 执行命令
print('任务执行完成!')
def timming_exe(cmd, inc=60):
schedule.enter(inc, 0, command, (cmd,))
schedule.run() # 运行调试器
timming_exe(r"F: && cd F:\program\Python\Python案例集锦\svn\资源包\Code\05\源程序\foo && python main.py", 1 * 60)
python C:\Python37\autorun.py
pause
import win32api &

这段代码展示了如何使用Python的`sched`模块实现定时执行命令,并通过`win32api`模块将Python脚本设置为Windows开机自启动。定时任务通过`timming_exe`函数设置,而添加到启动项的部分则通过读写注册表实现。
订阅专栏 解锁全文
8384

被折叠的 条评论
为什么被折叠?



