How Will You Run A Subprocess Or An External Program With Arguments In Python?


There are two methods which can run a subprocess or external programs. First is to use the subprocess module in the stdlib.

from subprocess import call
call(["ls", "-l"])

The advantage of subprocess vs system is that it is more flexible. You can get the stdout, stderr, the “real” status code and better error handling. The second approach to run a program with arguments is as follows.




© 2017