使用子进程时的FileNotFoundError

时间:2018-03-04 16:15:17

标签: python-3.x subprocess file-not-found

from subprocess import check_output
output=check_output(["ls", "F:\myData\input"]).decode("utf8")
print(ouptut)

我试图运行此代码来查看此目录中的文件并将结果保存为输出,但此行在执行时抛出错误。

任何人都可以帮我解决这个问题并理解这个问题吗?

Traceback (most recent call last):
  File "F:\myData\input\Analysis.py", line 21, in <module>
    output=check_output(["ls", "F:\myData\input\Analysis.py]).decode("utf8")
  File "C:\Users\Abhinav\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Users\Abhinav\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Abhinav\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Abhinav\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

0 个答案:

没有答案