os.path.exists无法识别C:\Windows\system32\drivers下的子目录

2024-10-01 17:24:54 发布

您现在位置:Python中文网/ 问答频道 /正文

有谁能告诉我为什么会出现这种行为:

C:\...>dir C:\Windows\System32\drivers\subdir\0xDEADBEEF.008
 Volume in drive C is Win7HPx64
 Volume Serial Number is 04BF-EE2E

 Directory of C:\Windows\System32\drivers\subdir\0xDEADBEEF.008

08/11/2011  04:21 PM    <DIR>          .
08/11/2011  04:21 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  11,581,788,160 bytes free

C:\...>C:\Python27\python.exe
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> silo = r'C:\Windows\System32\drivers\subdir\0xDEADBEEF.008'
>>> os.path.isdir(silo)
False
>>> os.path.exists(silo)
False

该目录上的os.stat引发WindowsError:“[错误3]系统找不到指定的路径….”

我也尝试过用“以管理员身份运行”上下文菜单启动的cmd控制台。没有骰子:

running as administrator


Tags: pathinfalsebytesisoswindowsdir
1条回答
网友
1楼 · 发布于 2024-10-01 17:24:54

如果您使用的是64位Windows上的32位Python构建,那么对C:\Windows\SYSTEM32的访问将透明地重定向到C:\Windows\SYSWOW64。在64位系统上,SYSTEM32包含64位dll,SYSWOW64包含32位dll。在

要从32位Python访问real SYSTEM32目录,请使用C:\WINDOWS\SYSNATIVE。在

http://msdn.microsoft.com/en-us/library/aa384187%28v=vs.85%29.aspx

相关问题 更多 >

    热门问题