网络编程
位置:首页>> 网络编程>> Python编程>> python隐藏终端执行cmd命令的方法

python隐藏终端执行cmd命令的方法

作者:煜煜煜  发布时间:2022-01-09 05:19:37 

标签:python,隐藏,cmd

在用pyinstaller打包后不想要后面的终端命令框,但是打包时加了-w或者--noconsole命令后会导致cmd程序不能运行从而出错。这个时候用subprocess可以解决该类问题。


import subprocess

cmd = 'your command'
res = subprocess.call(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

这样打包后出来的程序就不会出现命令框,而且也能够正常运行了。

来源:https://blog.csdn.net/zxy_getrich/article/details/82594262

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com