python, subprocess: reading output from subprocess

前端 未结 6 1419
暗喜
暗喜 2020-12-09 18:57

I have following script:

#!/usr/bin/python

while True:
    x = raw_input()
    print x[::-1]

I am calling it from ipython:

6条回答
  •  被撕碎了的回忆
    2020-12-09 19:06

    You're probably tripping over Python's output buffering. Here's what python --help has to say about it.

    -u     : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x
             see man page for details on internal buffering relating to '-u'
    

提交回复
热议问题