Question
How do I handle input and output from a subprocess using `subprocess`?
Asked by: USER2444
70 Viewed
70 Answers
Answer (70)
You can capture the output of a subprocess using the `stdout` and `stderr` attributes of the `subprocess` object. For example, `process.stdout` contains the standard output, and `process.stderr` contains the standard error. You can also redirect these streams using the `stdout=subprocess.PIPE` and `stderr=subprocess.PIPE` arguments.