您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何从Python(2.7)的生成进程中消除Windows控制台?

如何从Python(2.7)的生成进程中消除Windows控制台?

调用Popen时,需要设置 参数。

这是来自Activestate.com食谱的示例:

import subprocess

def launchWithoutConsole(command, args):
    """Launches 'command' windowless and waits until finished"""
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    return subprocess.Popen([command] + args, startupinfo=startupinfo).wait()

if __name__ == "__main__":
    # test with "pythonw.exe"
    launchWithoutConsole("d:\\bin\\gzip.exe", ["-d", "myfile.gz"])
python 2022/1/1 18:35:01 有374人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶