Multiple inputs and outputs in python subprocess communicate
问题 I need to do something like this post, but I need to create a subprocess that can be given input and give output many times. The accepted answer of that post has good code... from subprocess import Popen, PIPE, STDOUT p = Popen([\'grep\', \'f\'], stdout=PIPE, stdin=PIPE, stderr=STDOUT) grep_stdout = p.communicate(input=b\'one\\ntwo\\nthree\\nfour\\nfive\\nsix\\n\')[0] print(grep_stdout.decode()) # four # five ...that I would like to continue like this: grep_stdout2 = p.communicate(input=b\