[英]How to send data file into an application through python
I read about the subprocess module and I found out that it is possible to send data-file (txt) into application that has been called through the subprocess module in python like:我阅读了 subprocess 模块,发现可以将数据文件(txt)发送到通过 python 中的 subprocess 模块调用的应用程序中,例如:
import subprocess
f = open('data-file.txt', 'r')
with subprocess.Popen('runsoftware.exe', stdout=subprocess.PIPE,
stdin=f)as p:
stdout, stderr = p.communicate()
sleep(1)
subprocess.Popen.kill(p)
but nothing happens.但什么也没发生。 Is there any better way of sending data-file into an application?
有没有更好的方法将数据文件发送到应用程序中?
import subprocess
f = open('data-file.txt', 'r')
with subprocess.Popen('runsoftware.exe', stdout=subprocess.PIPE,
stdin=f)as p:
stdout, stderr = p.communicate()
sleep(1)
subprocess.Popen.kill(p)
Should send a file.应该发个文件。 Also you should close the file at the end or your code.
此外,您应该在最后关闭文件或您的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.