最佳答案
我已经找到了关于 subprocess.check _ output ()的文档,但是我找不到带参数的文档,而且文档也不是很深入。我正在使用 Python3(但是正在尝试通过 Python3运行 Python2文件)
我正在尝试运行这个命令:
python py2.py -i test.txt
- i 是 argparse 的位置参数,test.txt 是-i,py2.py 是要运行的文件
我已经尝试了很多(非工作)变化,包括:
py2output = subprocess.check_output([str('python py2.py '),'-i', 'test.txt'])
py2output = subprocess.check_output([str('python'),'py2.py','-i', test.txt'])