我有一個使用子python腳本:窗口 - 直接VS運行蟒蛇blah.py運行的.py行爲不同
import subprocess
print "Running stuff"
subprocess.check_call(["do_stuff.bat"])
print "Stuff run"
如果這個被命名爲blah.py,我跑(從命令提示符) :
python blah.py
我將得到do_stuff.bat(或任何我運行的)的輸出。
如果這樣運行的:
blah.py
然後,我沒有得到來自do_stuff.bat輸出,只打印報表。
到目前爲止在Windows Server 2003上出現過。Python版本2.5.2(由於各種原因卡在那裏)。 望着關聯的文件類型的動作我看:
Python.File = 「C:\ Python25 \ python.exe」 「%1」 %*
因此,誰能解釋的區別?
我會大膽地猜測,說顯式調用蟒蛇使得終端標準出來,而只是調用文件管道在其他地方標準化。我無法確認這個預感。 – Exelian
在運行Python 2.6.6的Windows 7 64位上,從批處理中輸出的數據在自行調用blah.py之後會打印到屏幕上。 – Helbreder
在我的Windows 7 32位上運行Python 2.6.6無法重現它。 –