如何在 python 中打开一个 exe 文件并在不关闭 exe 文件的情况下继续?

How to open an exe file in python and continue without close exe file?

我写了这段代码:

import subprocess

subprocess.call(["notepad.exe"], creationflags=subprocess.CREATE_NEW_CONSOLE)
print('I continue working.')

但在我关闭记事本之前我的脚本不会继续 运行。如何在不关闭此文件的情况下打开文件并继续 运行 脚本?

为此,您可以像这样使用 subprocess.Popen 方法:

process = subprocess.Popen("notepad.exe", shell=True, stdin=subprocess.PIPE)

如果您想以任何方式与使用该函数调用的进程进行交互,您可能需要阅读有关管道的内容并深入研究子进程模块。

相关问题:How to start a background process in Python?