我使用Python 2.7.6和IDLE在Windows 7的Python腳本IDLE不顯示子進程的輸出,但CMD.EXE確實
我有兩個Python腳本:
script.py:
import subprocess, os, sys
print("hello 1")
mypath = os.path.abspath(__file__)
mydir = os.path.dirname(mypath)
start = os.path.join(mydir, "script2.py")
subprocess.call([sys.executable, start, "param"])
print("bye 1")
和script2.py正在由以前的腳本調用:
import sys
print "hello 2"
print (sys.argv[1])
print "bye 2"
如果我跑script.py w ^第i個cmd.exe shell中我得到預期的結果:
C:\tests>python ./script.py
hello 1
hello 2
param
bye 2
bye 1
但是,如果我打開script.py與IDLE編輯器,並與F5運行它,我得到這樣的結果:
>>> ================================ RESTART ================================
>>>
hello 1
bye 1
>>>
爲什麼子不寫入IDLE Python shell的腳本?