[英]wait a process to finish in Python script
I'm writing a Python script to run several executables one by one on Windows. 我正在编写一个Python脚本,以在Windows上逐个运行多个可执行文件。 I need to wait a program to finish before starting the next.
我需要等待一个程序完成才能开始下一个。
So the script will be like this. 因此脚本将像这样。
1: launch a.exe
2: wait till a.exe finishes running
3: launch b.exe
4: wait till b.exe finishes
Anyone have an idea how to make the script waiting for a process to finish in Python? 有人知道如何使脚本等待Python中的进程完成吗?
Thanks 谢谢
If you wish to wait for your launched process, you can simply use subprocess.call() . 如果您希望等待启动的进程,则只需使用subprocess.call()即可。 This method executes the command in args and waits for it to complete.
此方法在args中执行命令并等待其完成。 For reference, see this
供参考,请参阅此
import subprocess
subprocess.call(('someprog.exe', str(i)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.