Asked By – Arovit
What is the difference between
Now we will see solution for issue: Difference between subprocess.Popen and os.system
If you check out the subprocess section of the Python docs, you’ll notice there is an example of how to replace
sts = os.system("mycmd" + " myarg")
…does the same thing as…
sts = Popen("mycmd" + " myarg", shell=True).wait()
The “improved” code looks more complicated, but it’s better because once you know
subprocess.Popen(), you don’t need anything else.
subprocess.Popen() replaces several other tools (
os.system() is just one of those) that were scattered throughout three other Python modules.
If it helps, think of
subprocess.Popen() as a very flexible