简体   繁体   English

在Python中有可能发生这种情况吗?

[英]Is something like this possible in Python?

I have an executable file (hello.exe) that was given to me by a friend. 我有一个朋友给我的可执行文件(hello.exe)。 This executable file creates another exe file (test.exe) and runs the executable through another command line window. 该可执行文件创建另一个exe文件(test.exe),并通过另一个命令行窗口运行该可执行文件。 I wanted to was attempting to write a script that ran hello.exe, and grabbed the output of test.exe. 我想尝试编写运行hello.exe的脚本,并获取test.exe的输出。 I'm very new to python and am familiar with system calls and redirecting output, but this is a special case because I am not directly accessing test.exe. 我是python的新手,熟悉系统调用和重定向输出,但这是一种特殊情况,因为我没有直接访问test.exe。 Another problem I am facing is that hello.exe waits for a keyboard response from test.exe before doing anything else. 我面临的另一个问题是hello.exe在执行其他操作之前会等待来自test.exe的键盘响应。 Is it possible for me to run my hello.exe script and grab the output from test.exe in the same script? 是否可以运行hello.exe脚本并在同一脚本中获取test.exe的输出?

import sys, string, os

os.system(hello.exe) > "test.txt" //Something like this?? Grab output from test.exe and put in test.txt
print "test" //this doesn't print until keystroke from terminal running test.exe

perhaps 也许

os.system("hello.exe > test.txt")

alternatively 或者

subprocess.Popen("hello.exe",stdout=open("test.txt","w")).communicate("\n")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用 AND 运算符之类的东西编写 Python 正则表达式? - Is it possible to write Python regexp with something like AND operator? 是否有可能以类似return的方式结束python模块导入? - Is it possible to end a python module import with something like a return? 像DebuggerDisplay for Python一样? - Something like DebuggerDisplay for Python? python类似assertFunctionNotCalled吗? - python something like assertFunctionNotCalled? Python &lt;3中是否有类似“ nonlocal”的东西? - Is there something like 'nonlocal' in Python < 3? 是否有类似logcat的python工具? - Is there something like logcat for python? 如何使用python以编程方式创建Google表单?是否可以通过appscript和python接口或类似方法来实现? - How to create a Google form programatically with python ?Is it possible to do so by appscript and python interfacing or something like that? 对于Python单元测试,有类似“自动测试”的东西吗? - Is there something like 'autotest' for Python unittests? 使用 RStudio 之类的东西开发 Python - Develop Python with something like RStudio 在 Javascript 或 Python 中是否有可能在 R 中实现诸如“非标准评估”之类的东西? - Would it be possible in Javascript or Python to implement something like "non standard evaluation" in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM