Python脚本在继续

时间:2018-04-11 16:36:04

标签: python windows command external

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

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

在脚本结束时,我想打开这个文本文件,以便用户可以直接看到输出。

osCommandString = "notepad.exe " + debug
os.system(osCommandString)

是的......这是关于Windows的开发。 不幸的是,python脚本在继续之前等待该用户关闭记事本。

有关如何解决该问题的任何想法?

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

请改用Subprocess模块​​。

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

osCommandString = "notepad.exe " + debug
subprocess.Popen(osCommandString)

您可以在此处详细了解:

https://docs.python.org/2/library/subprocess.html

答案 1 :(得分:0)

谢谢! 我正在使用

subprocess.call(osCommandString)
相关问题