计算机技术

bat批处理执行python

bat执行Python文件:

  1. @echo off
  2. D:
  3. cd D:WORKSPACEPython27test
  4. start python sendEmail.py
  5. exit

程序運行的很正常,可是伴隨著一個黑色的DOS窗口

PYTHON_HOME下有一個”pythonw.exe”

“pythonw.exe”和”python.exe”的區別:

1)”pythonw.exe”執行時不會出現DOS窗口

2)”pythonw.exe”執行時所有stdin和stdout都無效

3)”pythonw.exe”執行時從原有的sdtin只會得到EOF

所以最終結果:

  1. @echo off
  2. D:
  3. cd D:WORKSPACEPython27test
  4. start pythonw sendEmail.py
  5. exit

Related Articles

发表回复

Check Also
Close
Back to top button