Windows 定时执行 Python 程序

文章目录

计划任务

  • 找到 “控制面板-计划任务”
    Windows 定时执行 Python 程序

  • 创建基本任务
    Windows 定时执行 Python 程序

  • 填写名称、描述
    Windows 定时执行 Python 程序

  • 设置触发时间
    Windows 定时执行 Python 程序
    Windows 定时执行 Python 程序

  • 设置执行动作
    Windows 定时执行 Python 程序

  • 选择 pythonw.exe,添加参数,即要执行的 .py 文件。
    Windows 定时执行 Python 程序

  • 完成。在面板中间可看到新建的任务,双击或右键,可编辑、运行。
    Windows 定时执行 Python 程序

注意事项

  • python.exe 与 pythonw.exe
    python.exe 会弹出命令行的框,pythonw.exe 不会。

  • 路径
    .py 文件中使用相对路径的,要改为绝对路径,否则找不到。