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

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

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

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

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

      Python 3 子进程模块在运行“dir"时抛出错误.在 Windows 上

      时间:2023-09-03
      <tfoot id='1llqz'></tfoot>

      <legend id='1llqz'><style id='1llqz'><dir id='1llqz'><q id='1llqz'></q></dir></style></legend>

      <small id='1llqz'></small><noframes id='1llqz'>

        <bdo id='1llqz'></bdo><ul id='1llqz'></ul>

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

              <tbody id='1llqz'></tbody>
              • 本文介绍了Python 3 子进程模块在运行“dir"时抛出错误.在 Windows 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                Python 3 中的这个简单程序会引发错误.可能是什么原因?这个问题是在我安装/重新安装 Python 3.5/3.6 之后出现的.Python 2.7 也安装在我的 PC(Windows 10 机器)上.

                This simple program in Python 3 throws errors. What could be the reason? This problem arose after I installed/reinstalled Python 3.5/3.6. Also Python 2.7 is installed on my PC (windows 10 machine).

                import subprocess 
                out = subprocess.check_output(['dir'])
                

                错误信息:

                文件C:Python36libsubprocess.py",第 336 行,在 check_output 中**kwargs).stdout

                File "C:Python36libsubprocess.py", line 336, in check_output **kwargs).stdout

                文件C:Python36libsubprocess.py",第 403 行,运行中使用 Popen(*popenargs, **kwargs) 作为进程:

                File "C:Python36libsubprocess.py", line 403, in run with Popen(*popenargs, **kwargs) as process:

                init 中的文件C:Python36libsubprocess.py",第 707 行restore_signals, start_new_session)

                File "C:Python36libsubprocess.py", line 707, in init restore_signals, start_new_session)

                文件C:Python36libsubprocess.py",第 990 行,在 _execute_child 中启动信息)

                File "C:Python36libsubprocess.py", line 990, in _execute_child startupinfo)

                FileNotFoundError: [WinError 2] 系统找不到文件指定

                FileNotFoundError: [WinError 2] The system cannot find the file specified

                推荐答案

                不是可执行文件,而是 内置到外壳.Python subprocess 模块找不到,所以报错了.

                It's not an executable, but built-in to the shell. Python subprocess module can't find it, so you got an error.

                如果您想使用 subprocess 模块,请使用一些现有的二进制文件,例如pythonnotepadping.如果您需要列出文件夹内容,请使用 os.listdiros.walk.

                If you would like to play with subprocess module, use some existing binary, e.g. python, notepad or ping. In case you need to list folder content, please use os.listdir or os.walk.

                这篇关于Python 3 子进程模块在运行“dir"时抛出错误.在 Windows 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将脚本连接/处理到 PySimpleGUI 按钮 下一篇:子进程中的`shell = True`中的`shell`是否意味着`bash`?

                相关文章

              • <legend id='0pKcr'><style id='0pKcr'><dir id='0pKcr'><q id='0pKcr'></q></dir></style></legend>

              • <tfoot id='0pKcr'></tfoot>

                  <small id='0pKcr'></small><noframes id='0pKcr'>

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