python-3.x - 使用输入从python运行exe文件并保存输出
问题描述
我想从python运行一个带有输入的exe文件并保存输出而不打印它,有人知道我该怎么做吗?
解决方案
是的你可以。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)
推荐阅读
- node.js - 无法使用 res.writeHead() 和 .end() 从节点服务器获取重定向响应
- python - Random.shuffle 出人意料地在循环内不起作用
- artifactory - 远程转到注册表到自托管的 Git 存储库(不是 Github/Gitlab/bitbucket)
- c# - Physics.OverlapSphere 未正确检测对撞机
- jquery - 如何使用 jQuery 选择第 m 个元素的第 n 个子元素
- typescript - 如何可靠地检测 TSLint 中的 TypeScript SyntaxKind?
- jquery - vue项目中如何安装jquery
- graph - Gremlin 获取存在连接它们的双向边的顶点
- javascript - 一个按钮运行一个功能,第二个按钮运行不同的功能,但前提是第一个功能运行
- amazon-web-services - AWS Step Functions 是否具有超时功能?