我找不到任何答案。其中一个命令行是对exe的调用,其返回值不相关。另一方面,代码的输出对我很重要。我需要与我写的另一个bat文件并行运行这个exe,但我找不到一种方法来获取输出并同时运行它。在python / cmd中有没有办法做到这一点?
在批处理文件中,您可以使用start XYZ
来运行没有阻塞的东西。如果你想使用python(我建议批处理),请使用subprocess
模块:
p1 = subprocess.Popen(["my.exe", "arg1", "arg2"])
p2 = subprocess.Popen(["cmd", "/c", "my.bat"])
p1.wait()
p2.wait()