Last active
June 30, 2022 23:14
-
-
Save jeromew21/5c1ede565993be880771cda81dbf9afc to your computer and use it in GitHub Desktop.
Run a shell command in Python and capture stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blocking version with `run` | |
output = subprocess.run(['ls', '-l'], capture_output=True).stdout.decode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment