os.path.exists does not recognize a subdirectory under C:\\Windows\\system32\\drivers

匿名 (未验证) 提交于 2019-12-03 10:10:24

问题:

Can anyone tell me why this behaviour is exhibited:

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 on said directory raises a WindowsError: "[Error 3] The system cannot find the path specified...."

I tried with a cmd console launched with "Run as administrator" context menu, too. No dice:

回答1:

If you're using a 32-bit Python build on 64-bit Windows, then accesses to C:\WINDOWS\SYSTEM32 will be transparently redirected to C:\WINDOWS\SYSWOW64. On 64-bit systems, SYSTEM32 contains 64-bit DLLs and SYSWOW64 contains 32-bit DLLs.

To access the real SYSTEM32 directory from a 32-bit Python, use C:\WINDOWS\SYSNATIVE.

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!