这是继续我以前的帖子。球拍程序和python程序之间的通信 - 2
communcation between racket program and python program
,如果我尝试保持这个循环中被写入和读取持续,它不工作了。
我的球拍代码:
#lang racket
(define-values (sp i o e)
(subprocess #f #f #f "C:/Python26/python.exe" "C:/Python26/hello.py"))
(define counter 40)
(let loop()
(display "play\n" o)
(flush-output o)
(display (read-line i))
(when (> counter 0) (loop)))
我的Python代码:hello.py
while 1:
input_var = raw_input()
print "you entered\n"
您可能希望考虑缩进代码以使其更具可读性(对于Python,可编译)。 – 2012-04-08 00:10:51
尝试'sys.stdin.read()'。 – Blender 2012-04-08 00:12:52
我用sys.stdin.readline()并没有帮助。我的程序仍然挂起。 – chom 2012-04-08 00:24:15