【发布时间】:2012-10-05 08:52:08
【问题描述】:
import subprocess
import sys
proc = subprocess.Popen(["program.exe"], stdin=subprocess.PIPE) #the cmd program opens
proc.communicate(input="filename.txt") #here the filename should be entered (runs)
#then the program asks to enter a number:
proc.communicate(input="1") #(the cmd stops here and nothing is passed)
proc.communicate(input="2") # (same not passing anything)
我如何使用 python 传递和与 cmd 通信。
谢谢。 (使用windows平台)
【问题讨论】:
-
为什么不把receiver进程的相关部分也贴在这里?
-
可以试试
proc.stdin.write(data_to_write)
标签: python windows cmd subprocess communicate