简体   繁体   中英

Python Sub-process (Output PIPE)

How can I read from output PIPE multiple times without using process.communicate() as communicate closes the PIPE after reading the output but I need to have sequential inputs and outputs.

For example,

1) process.stdin.write('input_1')

2) After that, I need to read the output PIPE (how can I accomplish that without using communicate as it closes the PIPE ) and then give another input as

3) process.stdin.write('input_2')

4) And then read the output of step 3

But if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed.

Kindly help please.

flush() stdin,然后read() stdout。

代替process.communicate() ,使用process.stdout.read()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM