【问题标题】:run exe file from python with input and saving the output使用输入从python运行exe文件并保存输出
【发布时间】:2018-12-08 21:18:53
【问题描述】:

我想从 python 运行一个带有输入的 exe 文件并保存输出而不打印它,有人知道我该怎么做吗?

【问题讨论】:

    标签: python-3.x exe user-input python-3.3


    【解决方案1】:

    是的,你可以。 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)
    

    【讨论】:

      猜你喜欢
      • 2018-12-13
      • 2015-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多