I have this python code:
import os
try:
os.system(\'wrongcommand\')
except:
print(\"command does not work\")
The code prints:
Because os.system() indicates a failure through the exit code of the method
The exit code of the called command is directly passed back to Python.
There is documentation telling you that os.system() would raise an exeption in case of a failure. os.system() just calls the underlaying system() call of the OS and returns its return value.
Please read the os.system() documentation carefully.