I can execute a terminal command using os.system() but I want to capture the output of this command. How can I do this?
os.system()
The recommended way in Python 3.5 and above is to use subprocess.run():
subprocess.run()
from subprocess import run output = run("pwd", capture_output=True).stdout