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进行通信。如何使用python与命令行程序进行通信?
谢谢。 (使用Windows平台)
你为什么不在这里粘贴接收器进程的相关部分? – Dhara
可以尝试类似'proc.stdin.write(data_to_write)' – avasal
这是重复的。 –