1. <small id='A5KPx'></small><noframes id='A5KPx'>

    2. <tfoot id='A5KPx'></tfoot>
    3. <legend id='A5KPx'><style id='A5KPx'><dir id='A5KPx'><q id='A5KPx'></q></dir></style></legend>

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

        子进程中的python getoutput()等价物

        python getoutput() equivalent in subprocess(子进程中的python getoutput()等价物)

          • <bdo id='8rxHa'></bdo><ul id='8rxHa'></ul>

            <legend id='8rxHa'><style id='8rxHa'><dir id='8rxHa'><q id='8rxHa'></q></dir></style></legend>
              <tbody id='8rxHa'></tbody>

          • <tfoot id='8rxHa'></tfoot>
          • <small id='8rxHa'></small><noframes id='8rxHa'>

                <i id='8rxHa'><tr id='8rxHa'><dt id='8rxHa'><q id='8rxHa'><span id='8rxHa'><b id='8rxHa'><form id='8rxHa'><ins id='8rxHa'></ins><ul id='8rxHa'></ul><sub id='8rxHa'></sub></form><legend id='8rxHa'></legend><bdo id='8rxHa'><pre id='8rxHa'><center id='8rxHa'></center></pre></bdo></b><th id='8rxHa'></th></span></q></dt></tr></i><div id='8rxHa'><tfoot id='8rxHa'></tfoot><dl id='8rxHa'><fieldset id='8rxHa'></fieldset></dl></div>
                  本文介绍了子进程中的python getoutput()等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想从 python 脚本中的 lsdf 等一些 shell 命令获取输出.我看到 commands.getoutput('ls') 已被弃用,但 subprocess.call('ls') 只会让我得到返回码.

                  I want to get the output from some shell commands like ls or df in a python script. I see that commands.getoutput('ls') is deprecated but subprocess.call('ls') will only get me the return code.

                  我希望有一些简单的解决方案.

                  I'll hope there is some simple solution.

                  推荐答案

                  使用subprocess.Popen:

                  import subprocess
                  process = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                  out, err = process.communicate()
                  print(out)
                  

                  请注意,通信会阻塞,直到进程终止.如果您需要在输出终止之前输出,您可以使用 process.stdout.readline().有关详细信息,请参阅 文档.

                  Note that communicate blocks until the process terminates. You could use process.stdout.readline() if you need the output before it terminates. For more information see the documentation.

                  这篇关于子进程中的python getoutput()等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

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

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

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

                          • <legend id='JsgJG'><style id='JsgJG'><dir id='JsgJG'><q id='JsgJG'></q></dir></style></legend>
                              <tbody id='JsgJG'></tbody>