subprocess.check_output python code example
Example 1: subprocess.check_output python
import subprocess
py2output = subprocess.check_output(['python', 'py2.py', '-i', 'test.txt'])
print('py2 said:', py2output)
Example 2: python subprocess exception handling
try:
subprocess.check_output(...)
except subprocess.CalledProcessError as e:
print(e.output)