Read more in Python shell guide.

result = subprocess.run(cmd, capture_output=True, text=True, shell=True)
exitcode, data = subprocess.getstatusoutput(cmd)