【发布时间】:2019-01-26 11:04:09
【问题描述】:
路径 = 批处理文件的位置。(c:....\a.bat)
并且 a.bat 包含以下数据: 开始 C:\Python27\python.exe "C:.....\test.py"
我有以下代码:
my_process = subprocess.call(os.path.abspath(path), shell=True)
text_file = open("output.txt",r) # output.txt is batch file output
我希望代码应该等待批处理文件执行,并且批处理文件的输出应该生成 output.txt。 稍后 text_file = open("output.txt",r) 应该执行。
但代码不会等待批处理文件执行 & 很快就会生成找不到 output.txt 的错误。
【问题讨论】:
-
START /WAIT也许?
标签: python batch-file subprocess