没有这样的文件或目录错误

Ric*_*nop 3 python

这是我得到的错误:

Traceback (most recent call last):
  File "E:\stuff\module.py", line 91, in <module>
    f = open('E:/stuff/log.txt')
IOError: [Errno 2] No such file or directory: 'E:/stuff/log.txt'
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

f = open('E:/stuff/log.txt')
Run Code Online (Sandbox Code Playgroud)

E:/stuff/log.txt文件存在.我可以在Windows资源管理器中导航并打开它,为什么我不能打开它?

编辑:

输出DIR命令:

C:\Documents and Settings\Administrator>dir e:\stuff
 Volume in drive E has no label.
 Volume Serial Number is 5660-4957

 Directory of e:\stuff

23. 10. 2010  09:26    <DIR>          .
23. 10. 2010  09:26    <DIR>          ..
19. 10. 2010  20:07               385 index.py
23. 10. 2010  16:12             1 954 module.py
22. 10. 2010  19:16             8 335 backprop.py
19. 10. 2010  20:54             1 307 backprop-input.gif
19. 10. 2010  01:48               310 HelloWorld.kpf
23. 10. 2010  15:47                 0 log.txt.txt
               6 File(s)         12 291 bytes
               2 Dir(s)   8 795 586 560 bytes free



C:\Documents and Settings\Administrator>dir e:\
 Volume in drive E has no label.
 Volume Serial Number is 5660-4957

 Directory of e:\

16. 10. 2010  13:32    <DIR>          development-tools
23. 10. 2010  09:26    <DIR>          stuff
               0 File(s)              0 bytes
               2 Dir(s)   8 795 586 560 bytes free
Run Code Online (Sandbox Code Playgroud)

我从cmd运行python脚本,如下所示:

python E:\stuff\module.py
Run Code Online (Sandbox Code Playgroud)

Tim*_*Čas 10

首先,从上面看,Windows支持/就好了.

其次:好吧,如果你查看你的文件,你会注意到它不是log.txt,它是log.txt.txt ......你可能会在你的图形文件夹查看器中看到它是"log.txt"(而不是CLI"dir"命令)只是因为它隐藏了已知的文件扩展名.

我建议您禁用此功能 - 请参阅文件夹选项,应该有一个选项"隐藏已知文件类型的扩展名"(或类似).