这是我收到的错误:没有这样的文件或目录错误
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'
这是我的代码:
f = open('E:/stuff/log.txt')
的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
我从这样的CMD运行python脚本:
python E:\stuff\module.py
“我可以在Windows资源管理器中导航”。所以?从命令提示符处执行“DIR”命令并复制并粘贴该命令。 – 2010-10-23 13:58:41
@S。洛特我做到了。看到我更新的问题。 – 2010-10-23 14:11:03
@Richard:那不是命令提示符,那是python解释器。 – SilentGhost 2010-10-23 14:13:58