设置参数: creationflags=0x08000000 可以隐藏命令行窗口
def run(self):
# creationflags=0x08000000 使用 pyinstaller 打包成 exe 时隐藏命令行窗口
self.process = subprocess.Popen(self.cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1,creationflags=0x08000000)
while self.process.poll() is None:
out = self.process.stdout.readline().decode("utf-8").strip()
self.log.emit(out)
本文介绍了一种在使用Python的subprocess模块时,通过设置creationflags参数为0x08000000来隐藏命令行窗口的方法。此技巧特别适用于使用PyInstaller将Python脚本打包成exe文件时,避免在运行过程中显示不必要的命令行界面。

被折叠的 条评论
为什么被折叠?



