我想从python运行带有输入的exe文件,并保存输出而不打印它,有人知道我该怎么做吗?
答案 0 :(得分:0)
是的,可以。 https://docs.python.org/2/library/subprocess.html#module-subprocess
import subprocess
with open('mylog.txt', 'a') as log, open('myerror.txt', 'a') as error_log:
process = subprocess.call(['ls', '-l'], stderr=error_log, stdout=log)