我需要在Python中的Popen调用中使用流重定向来将bat文件与wine一起使用。我需要做这个:
wine32 cmd < file.bat
当我从终端手动运行它时它可以工作,但是当我尝试从 python 调用它时:
proc = Popen('wine32 cmd < file.bat',stdout = PIPE)
我收到错误:没有这样的文件或目录
如何管理?
谢谢
最佳答案
试试这个:
import sys
#...
with open('file.bat', 'r') as infile:
subprocess.Popen(['wine32', 'cmd'],
stdin=infile, stdout=sys.stdout, stderr=sys.stderr)
确保 wine32
的每个参数都是一个单独的列表元素。
关于python - 在 python 中使用 Popen 输入重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28125255/