如何关闭python的命令提示符窗口

import os
os.system('firefox.exe')

python 窗口

我把上面这段python 代码 编译成了exe ,启动firefox后,中间那个cmd.exe 会启动着,有什么办法隐藏这个cmd 窗口?

阅读 17.2k
2 个回答

不使用 cmd.exe 就是了。

使用subprocess.Popen并且不要指定shell=True

新手上路,请多包涵

testx1=subprocess.Popen(r"C:UserscoolVideosthunder_shortcut.lnk",shell=True)
time.sleep(1)#等待使子进程打开
testx1.kill()#关闭cmd窗口

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题