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

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

      • <bdo id='jRmhr'></bdo><ul id='jRmhr'></ul>

        如何使用 python 在多个终端窗口中运行多个文件

        How do you run multiple files in multiple terminal windows using python(如何使用 python 在多个终端窗口中运行多个文件)
      1. <small id='tAYld'></small><noframes id='tAYld'>

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

          <tfoot id='tAYld'></tfoot>

                <bdo id='tAYld'></bdo><ul id='tAYld'></ul>
                • <legend id='tAYld'><style id='tAYld'><dir id='tAYld'><q id='tAYld'></q></dir></style></legend>
                    <tbody id='tAYld'></tbody>
                • 本文介绍了如何使用 python 在多个终端窗口中运行多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  from subprocess import call
                  call(["python3", "/home/johngr/psdirc/TestBot1.py"]) and call(["python3", "/home/johngr/psdirc/TestBot2.py"]) and call(["python3", "/home/johngr/psdirc/TestBot3.py"])
                  

                  调用正常,但它只运行第一个文件.我希望它们都在自己的终端窗口中运行.

                  The call is working but it only runs the first file. I want them all to run in their own terminal windows.

                  推荐答案

                  不要使用一个接一个地运行:

                  Don't use and just run one after the other:

                  call(["python3", "/home/johngr/psdirc/TestBot1.py"])
                  call(["python3", "/home/johngr/psdirc/TestBot2.py"])
                  call(["python3", "/home/johngr/psdirc/TestBot3.py"])
                  

                  如果您不希望他们在开始下一次使用 Popen 之前等待进程完成:

                  If you don't want them to wait for the process to finish before starting the next use Popen:

                   Popen(["python3", "/home/johngr/psdirc/TestBot1.py"])
                   Popen(["python3", "/home/johngr/psdirc/TestBot2.py"])
                   Popen(["python3", "/home/johngr/psdirc/TestBot3.py"])
                  

                  call运行 args 描述的命令.等待命令完成,然后返回 returncode 属性. Popen 不会等待.

                  如果您想确保每个进程以非零退出状态退出,请使用 check_call 对于任何非零退出状态都会引发 CalledProcessError.

                  If you want to be sure each process exits with a non-zero exit status use check_call which will raise a CalledProcessError for any non-zero exit status.

                  要为每个终端打开一个终端,您可以使用 gnome-terminal-e 在终端内执行此选项的参数:

                  To open a terminal for each you can use gnome-terminal with -e Execute the argument to this option inside the terminal:

                  call(['gnome-terminal', '-e', "python3 /home/johngr/psdirc/TestBot1.py"])
                  call(['gnome-terminal', '-e', "python3 /home/johngr/psdirc/TestBot2.py"])
                  call(['gnome-terminal', '-e', "python3 /home/johngr/psdirc/TestBot3.py"])
                  

                  如果你想打开标签,你可以使用 --tab -e:

                  If you want to open tabs you can use --tab -e:

                  cmd =['gnome-terminal', '--tab', '-e', 'python3 /home/johngr/psdirc/TestBot1.py',
                        '--tab', '-e','python3 /home/johngr/psdirc/TestBot2.py','--tab', '-e', 
                        'python 3 /home/johngr/psdirc/TestBot3.py']
                  call(cmd)
                  

                  您似乎没有 gnome-terminal 所以只需将其替换为 lxterminal:

                  You don't seem to have gnome-terminal so just replace it with lxterminal:

                  call(['lxterminal', '-e', 'python3 /home/johngr/psdirc/TestBot1.py'])
                  

                  不确定是否支持 --tab 选项,我在文档中没有看到对它的任何引用.

                  Not sure if --tab option is supported or not, I don't see any reference to it in the documentation.

                  这篇关于如何使用 python 在多个终端窗口中运行多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                • <small id='pMWEM'></small><noframes id='pMWEM'>

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

                            <tbody id='pMWEM'></tbody>