Skip to content

Instantly share code, notes, and snippets.

@ram1123
Last active July 4, 2018 11:16
Show Gist options
  • Save ram1123/9730b76eabe5a46f196a32597f6abe2e to your computer and use it in GitHub Desktop.
Save ram1123/9730b76eabe5a46f196a32597f6abe2e to your computer and use it in GitHub Desktop.
how to store output of a command in a variable using python

(Python) How to store output of command in a variable

import subprocess

command = "ls -ltrh"

output = subprocess.check_output(command, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment