def test_HFG(self):
#....
print "please edit this file"
os.chdir(r'C:\test\a')
os.startfile("myfile.vdx")
# here I need a "stop until the program is closed"-function
#....
startfile() returns as soon as the associated application is
launched. There is no option to wait for the application to close, and
no way to retrieve the application’s exit status.
startfile() returns as soon as the associated application is launched.
There is no option to wait for the application to close, and no way to
retrieve the application’s exit status
从文件中:
如果您知道要打开文件的应用程序的路径,则可以使用子流程.Popen()让您可以等待。在
参见: http://docs.python.org/library/os.html#os.startfile
http://docs.python.org/library/subprocess.html#subprocess.Popen
os.startfile
的文档明确指出:因此,我建议使用另一种方法,例如通过
subprocess.Popen
启动它,这允许您等待子进程完成。在当然,
os.startfile
是完全非阻塞的,没有等待的选项。在我建议使用subprocess模块,调用Windows“start”命令打开带有关联对象的文件,这与
os.startfile
的操作相同,但允许您等待进程完成。在例如:
相关问题 更多 >
编程相关推荐