Skip to content

Instantly share code, notes, and snippets.

@jeromew21
Last active June 30, 2022 23:14
Show Gist options
  • Save jeromew21/5c1ede565993be880771cda81dbf9afc to your computer and use it in GitHub Desktop.
Save jeromew21/5c1ede565993be880771cda81dbf9afc to your computer and use it in GitHub Desktop.
Run a shell command in Python and capture stdout
# 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