Python Forum

Full Version: How to get program output from subprocess.Popen?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I need to run a standalone app from my Python 3.7.3 script in a separate window, wait its completion and after that parse its output in my script. How can I have it done in my Python script?
you can use convenient subprocess.run() and pass capture_output=True. e.g.

import subprocess
result = subprocess.run(['ls'], capture_output=True) # running linux ls command
print(result.stdout.decode())