import subprocess # Run a shell command and capture its output output = subprocess.check_output("ls -l", shell=True) print(output.decode())