繁体   English   中英

Python 和 Windows 调度程序 - 运行调用其他脚本的 py 脚本

[英]Python and windows scheduler - run py script that invokes other scripts

我正在尝试设置一个 Windows 计划任务来运行一个运行其他两个脚本的 python 脚本。 我使用 os 包来完成它的代码如下:

#mainScript.py
    import os
    
        os.system('script1.py 1')
        os.system('scripts.py 1')

该脚本在计划任务中工作,除非我添加了上述代码。 我的意思如果在我的 bat 文件中使用 script1.py 它可以工作,但是如果我使用 mainScript.py 它会给我错误代码。

'script1.py' is not recognized as an internal or external command,
operable program or batch file.
'script2.py' is not recognized as an internal or external command,
operable program or batch file.

我知道我可以将所有代码移动到mainScript 中,但想知道是否有什么我可以做的。

您需要指定将运行脚本的程序。 尝试这个 :

os.system('python script1.py')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM