How to run an external script in Python
Python offers a subprocess module for you to run external script, which is more flexible than its os.system() function. It provides more powerful facilities for spawning new processes and retrieving their results.
For instance,
import subprocess
subprocess.run(["ls", "-l"])
or for versions before Python 3.5, use the following:
import subprocess
subprocess.call(["ls", "-l"])
Comments
Post a Comment