subprocess.check_output python 3 code example
Example 1: pass variable in subprocess run python
#ran in python 3.8.x
cmd = "ls"
cmd_args = "-l"
subprocess.run([cmd, cmd_args])
Example 2: subprocess.check_output python
import subprocess
py2output = subprocess.check_output(['python', 'py2.py', '-i', 'test.txt'])
print('py2 said:', py2output)