python subprocess
Python subprocess examples Description This is a collection of python subprocess examples for easy usage. Although I found the python documents are very comprehensive, I found there is not much examples of showing how to use. This document act as a note of how to use python subprocess package.
Environment settings OS Windows 10 home python Anaconda, python 3.6.3 Main functions subprocess.run() the code is executed in IDLE command line window.
>>> import subprocess as sb >>> bash_exec = "C:\\Program Files\\Git\\bin\\bash.exe" >>> sb.run([bash_exe, '-c','pwd'], stdout=sb.PIPE) CompletedProcess(args=[‘C:\Program Files\Git\bin\bash.