Re: [問題] os.system輸入輸出

看板Python作者 (aaa)時間17年前 (2008/08/13 09:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
※ 引述《Arton0306 (Ar藤)》之銘言: : 如果我有一程式gcd.exe : 執行後使用者輸入兩數字enter後輸出其gcd 接著關閉 : 這樣是否有辦法利用os.system或其它函式 : 讓python中 兩變數x,y當輸入 : 而z儲存輸出 : (用檔案當中介 利用管線來執行 "之外的其它方法") 類似這樣? def gcd(x, y): gcd = subprocess.Popen("gcd.exe", stdin=subprocess.PIPE, stdout.subprocess.PIPE) gcd.stdin.write(x) gcd.stdin.write(y) return gcd.stdout.read() -- http://nigel.twbbs.org -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 76.95.86.77
文章代碼(AID): #18eZSRqk (Python)
討論串 (同標題文章)
文章代碼(AID): #18eZSRqk (Python)