我正在使用“ Popen”運行子流程。我需要阻塞直到該子進(jìn)程完成,然后再讀取其輸出。p = Popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE, encoding="utf-8")p.communicate():output = p.stdout.readline()print(output)我得到一個錯誤ValueError: I/O operation on closed file.子進(jìn)程完成后如何讀取輸出,我不希望使用poll(),因為子進(jìn)程需要時間,而且無論如何我都需要等待其完成。
添加回答
舉報
0/150
提交
取消