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

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

        • <bdo id='yVWlH'></bdo><ul id='yVWlH'></ul>
      1. 出现错误 - AttributeError: 'module' object has no attrib

        Getting an error - AttributeError: #39;module#39; object has no attribute #39;run#39; while running subprocess.run([quot;lsquot;, quot;-lquot;])(出现错误 - AttributeError: module object has no attribute run while running subprocess.run([ls,
      2. <small id='r7E4z'></small><noframes id='r7E4z'>

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

              <tfoot id='r7E4z'></tfoot>
                <tbody id='r7E4z'></tbody>

                  本文介绍了出现错误 - AttributeError: 'module' object has no attribute 'run' while running subprocess.run(["ls", "-l"])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 AIX 6.1 上运行并使用 Python 2.7.想要执行以下行,但出现错误.

                  I am running on a AIX 6.1 and using Python 2.7. Want to execute following line but getting an error.

                  subprocess.run(["ls", "-l"])
                  Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                  AttributeError: 'module' object has no attribute 'run'
                  

                  推荐答案

                  subprocess.run()函数只存在于Python 3.5及更新版本.

                  The subprocess.run() function only exists in Python 3.5 and newer.

                  然而,向后移植很容易:

                  It is easy enough to backport however:

                  def run(*popenargs, **kwargs):
                      input = kwargs.pop("input", None)
                      check = kwargs.pop("handle", False)
                  
                      if input is not None:
                          if 'stdin' in kwargs:
                              raise ValueError('stdin and input arguments may not both be used.')
                          kwargs['stdin'] = subprocess.PIPE
                  
                      process = subprocess.Popen(*popenargs, **kwargs)
                      try:
                          stdout, stderr = process.communicate(input)
                      except:
                          process.kill()
                          process.wait()
                          raise
                      retcode = process.poll()
                      if check and retcode:
                          raise subprocess.CalledProcessError(
                              retcode, process.args, output=stdout, stderr=stderr)
                      return retcode, stdout, stderr
                  

                  不支持超时,也不支持完成进程信息的自定义类,所以我只返回 retcodestdoutstderr信息.否则它和原来的一样.

                  There is no support for timeouts, and no custom class for completed process info, so I'm only returning the retcode, stdout and stderr information. Otherwise it does the same thing as the original.

                  这篇关于出现错误 - AttributeError: 'module' object has no attribute 'run' while running subprocess.run(["ls", "-l"])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 画布滚动条?)
                    <bdo id='oDppY'></bdo><ul id='oDppY'></ul>

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

                        1. <tfoot id='oDppY'></tfoot>
                        2. <small id='oDppY'></small><noframes id='oDppY'>

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

                              <tbody id='oDppY'></tbody>