这是我的代码,它可以定位文件ctfmon.exe
,但不能定位文件cc.dll
。
>>> import os
>>> os.path.exists("c:\\windows\\system32\\ctfmon.exe")
True
>>> os.path.exists("c:\\windows\\system32\\cc.dll")
False
但是,文件cc.dll
确实存在。
C:\Windows\System32>dir cc.dll
驱动器 C 中的卷没有标签。
卷的序列号是 B481-54FB
C:\Windows\System32 的目录
2014/04/17 14:12 0 cc.dll
1 个文件 0 字节
0 个目录 8,659,787,776 可用字节
发布于 2014-11-25 01:29:45
您正在64位版本的Windows上运行32位版本的python。在64位Windows中启动32位应用程序时,C:\Windows\SysWOW64将映射到C:\Windows\System32。
发布于 2014-04-17 14:17:33
试一下这个例子:
os.path.isfile("your address/your file")
它来自python文档
如果path引用现有路径,则os.path.exists(path)
返回True。对于断开的符号链接,返回False。在某些平台上,如果未授予对所请求文件执行 os.stat()
的权限,此函数可能会返回False,即使该路径实际存在。这可能是您的问题所在。
发布于 2014-04-17 14:18:12
尝试删除双斜杠..
import os
print os.path.exists("c:\\windows\system32\cca.dll")
或
print os.path.exists("""c:\\windows\system32\cca.dll""")
https://stackoverflow.com/questions/23125857
复制相似问题