• <i id='IVeKj'><tr id='IVeKj'><dt id='IVeKj'><q id='IVeKj'><span id='IVeKj'><b id='IVeKj'><form id='IVeKj'><ins id='IVeKj'></ins><ul id='IVeKj'></ul><sub id='IVeKj'></sub></form><legend id='IVeKj'></legend><bdo id='IVeKj'><pre id='IVeKj'><center id='IVeKj'></center></pre></bdo></b><th id='IVeKj'></th></span></q></dt></tr></i><div id='IVeKj'><tfoot id='IVeKj'></tfoot><dl id='IVeKj'><fieldset id='IVeKj'></fieldset></dl></div>
      <bdo id='IVeKj'></bdo><ul id='IVeKj'></ul>

    1. <tfoot id='IVeKj'></tfoot>

        <small id='IVeKj'></small><noframes id='IVeKj'>

        <legend id='IVeKj'><style id='IVeKj'><dir id='IVeKj'><q id='IVeKj'></q></dir></style></legend>

        从 Python 执行子进程而不打开 Windows 命令提示符

        时间:2023-07-21

        1. <tfoot id='6RsfT'></tfoot>

        2. <legend id='6RsfT'><style id='6RsfT'><dir id='6RsfT'><q id='6RsfT'></q></dir></style></legend>
              <i id='6RsfT'><tr id='6RsfT'><dt id='6RsfT'><q id='6RsfT'><span id='6RsfT'><b id='6RsfT'><form id='6RsfT'><ins id='6RsfT'></ins><ul id='6RsfT'></ul><sub id='6RsfT'></sub></form><legend id='6RsfT'></legend><bdo id='6RsfT'><pre id='6RsfT'><center id='6RsfT'></center></pre></bdo></b><th id='6RsfT'></th></span></q></dt></tr></i><div id='6RsfT'><tfoot id='6RsfT'></tfoot><dl id='6RsfT'><fieldset id='6RsfT'></fieldset></dl></div>

                <bdo id='6RsfT'></bdo><ul id='6RsfT'></ul>

                    <tbody id='6RsfT'></tbody>
                1. <small id='6RsfT'></small><noframes id='6RsfT'>

                  本文介绍了从 Python 执行子进程而不打开 Windows 命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  在没有控制台的情况下使用 Popen 在 pythonw 中运行进程
                  如何消除 Windows 控制台来自 Python (2.7) 中的衍生进程?

                  我有一个 Python 程序,它多次调用一个单独的数字处理程序(用 C 编写)作为子进程(使用 subprocess.check_call).它在 Linux 上运行良好,在 Windows 上也运行良好,除了一件小事:每次调用子进程时都会创建一个命令提示符窗口,然后在子进程退出时很快将其销毁.

                  I have a Python program that calls a separate number-crunching program (written in C) as a subprocess several times (using subprocess.check_call). It works great on Linux, and it works great on Windows too except for one little thing: every time it calls the subprocess a Command Prompt window is created and then soon destroyed when the subprocess exits.

                  这根本不影响计算,但是很烦人,因为这个窗口一直在屏幕上闪烁,并且在计算机上做其他事情变得困难,因为新的命令提示符窗口可以窃取键盘焦点.

                  This doesn't affect the computation at all, but it's very annoying because this window keeps flashing on and off the screen, and it makes it difficult to do other things on the computer because the new Command Prompt window can steal keyboard focus.

                  如何简单地执行子进程(没有 GUI),并防止创建命令提示符窗口?

                  How can I simply execute the subprocess (which has no GUI), and prevent the Command Prompt window from being created?

                  推荐答案

                  你是怎么调用subprocess.check_call()的?如果您传递 shell=True 则不应创建窗口,因为这将导致为 STARTUPINFO.wShowWindow 属性设置 SW_HIDE 标志.

                  How are you calling subprocess.check_call()? If you pass shell=True then the window should not be created as this will cause the SW_HIDE flag to be set for the STARTUPINFO.wShowWindow attribute.

                  例子:

                  subprocess.check_call(["ping", "google.com"], shell=True)
                  

                  这篇关于从 Python 执行子进程而不打开 Windows 命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python:执行 shell 命令 下一篇:无法使用子进程 [python] 向进程提供密码

                  相关文章

                  • <bdo id='EGwGx'></bdo><ul id='EGwGx'></ul>
                  1. <small id='EGwGx'></small><noframes id='EGwGx'>

                    <legend id='EGwGx'><style id='EGwGx'><dir id='EGwGx'><q id='EGwGx'></q></dir></style></legend>

                    <i id='EGwGx'><tr id='EGwGx'><dt id='EGwGx'><q id='EGwGx'><span id='EGwGx'><b id='EGwGx'><form id='EGwGx'><ins id='EGwGx'></ins><ul id='EGwGx'></ul><sub id='EGwGx'></sub></form><legend id='EGwGx'></legend><bdo id='EGwGx'><pre id='EGwGx'><center id='EGwGx'></center></pre></bdo></b><th id='EGwGx'></th></span></q></dt></tr></i><div id='EGwGx'><tfoot id='EGwGx'></tfoot><dl id='EGwGx'><fieldset id='EGwGx'></fieldset></dl></div>

                    1. <tfoot id='EGwGx'></tfoot>