Python 3 subprocess module throws error running “dir” on Windows

后端 未结 3 807
清歌不尽
清歌不尽 2021-01-06 22:58

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

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 23:12

    It seems that "dir" is not in your path. I do not know the full path of this executable on Windows but maybe you should replace dir by c:\windwos\system\dir

    Or a best solution would be to use functions in the os modules to list directories:

    os.listdir(path)
    

提交回复
热议问题