Python脚本在继续之前等待外部命令完成

Python脚本在继续之前等待外部命令完成,python,windows,command,external,Python,Windows,Command,External,我有一个非常简单的Python脚本,它解析somme数据并将输出写入文本文件 with open(debug, 'w') as debugFile: debugFile.write(metreDebug) 在脚本的末尾,我想打开这个文本文件,以便用户可以直接看到输出 osCommandString = "notepad.exe " + debug os.system(osCommandString) 是的。。。这是在windows上开发的。 不幸的是,python脚本会等待用户关闭记事本后

我有一个非常简单的Python脚本,它解析somme数据并将输出写入文本文件

with open(debug, 'w') as debugFile:
 debugFile.write(metreDebug)
在脚本的末尾,我想打开这个文本文件,以便用户可以直接看到输出

osCommandString = "notepad.exe " + debug
os.system(osCommandString)
是的。。。这是在windows上开发的。 不幸的是,python脚本会等待用户关闭记事本后再继续

关于如何解决这个问题有什么想法吗


谢谢您的帮助。

请改用子流程模块

import subprocess
with open(debug, 'w') as debugFile:
 debugFile.write(metreDebug)

osCommandString = "notepad.exe " + debug
subprocess.Popen(osCommandString)
您可以在此处阅读更多信息:

谢谢! 我在用

subprocess.call(osCommandString)

如果你真的想使用
os.system
,你必须使用
start notepad.exe
。但正如它自己的文档所解释的那样,您确实不应该使用
os.system