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
這是重複的。 –