* test11.py
import time
print "1"
time.sleep(2)
print "1"
time.sleep(2)
print "1"
time.sleep(2)
print "1"
* test.py
import subprocess p = subprocess.Popen("python test11.py", shell=True, stdout=subprocess.PIPE)
# None表示正在执行中
while p.poll() is None:
out = p.stdout.readline()
if out != "":
print out