子过程在Windows中无输出

发布于 2025-02-12 16:59:34 字数 421 浏览 0 评论 0原文

我需要运行带有不同参数的EXE文件,然后将输出写入文件。我尝试了以下脚本。程序运行后,输出文件为空。告诉我如何解决这个问题

import subprocess
output_f = open('output.txt', 'a')
for i in "abcdefghijklmnopqrstuvwxyz{}_":
    for j in "abcdefghijklmnopqrstuvwxyz{}_":
        program = 'C:/Users/PC/Desktop/task2 (1).exe ' + i +" " +j;
        process = subprocess.Popen(program,stdout=output_f)
        code = process.wait()
output_f.close()
print(code)

I need to run an exe file with different parameters and write the output to a file. I tried the following script. After the program is running, the output file is empty. Tell me how to solve this problem

import subprocess
output_f = open('output.txt', 'a')
for i in "abcdefghijklmnopqrstuvwxyz{}_":
    for j in "abcdefghijklmnopqrstuvwxyz{}_":
        program = 'C:/Users/PC/Desktop/task2 (1).exe ' + i +" " +j;
        process = subprocess.Popen(program,stdout=output_f)
        code = process.wait()
output_f.close()
print(code)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文