Usually I can change stdout in Python by changing the value of sys.stdout
. However, this only seems to affect print
statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system()
command in Python?
On a unix system, you can redirect stderr and stdout to /dev/null as part of the command itself.
os.system(cmd + "> /dev/null 2>&1")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With