
1 mengjue 2015 年 1 月 7 日 try pexpect module |
2 clino 2015 年 1 月 7 日 subprocess 可以啊,往 stdin 里面写不就行了吗? |
3 Delbert OP @clino @mengjue ```python concept_file = open('concepts.txt', 'rt') p = Popen('./distance vectors.bin', stdin=PIPE,stdout=PIPE, bufsize=1) time.sleep(30) word = concept_file.readline() print(word) Popen.stdin = word Popen.stdin = 'EXIT' print(p.stdout.readlines()) concept_file.close() ``` 之后就卡住了,一动不动,换成read()和readline()也都一样。。。。 |
4 clino 2015 年 1 月 7 日 问题出在 readlines https://docs.python.org/2/library/stdtypes.html#file.readlines 这个借口是一直阻塞直到读完的 你用楼上提到的 pexpect 吧,这个是专门做这种用途的吧 |
5 brickgao 2015 年 1 月 7 日 |