Python subprocess store stdout and stderr output in a variable | Sany's Linux and Open Source Blog

Python subprocess store stdout and stderr output in a variable | Sany's Linux and Open Source Blog

瀏覽:774
日期:2025-07-10
To store stdout and stderr output in a variable use following code: import os, sys, subprocess from subprocess import * #To store both stdout and stderr output1 = subprocess.check_output("cat fileNotExists.txt; exit 0", stderr=subprocess.STDOUT, shell=Tru...看更多