在我的windows7 64位系统中,文件夹c:/windows/system32
中有一个名为msconfig.exe
的文件。是的,它一定存在。
但是当我使用os.listdir
搜索文件夹c:/windows/system3
2时,我没有得到文件。这是测试代码,在t1.py
:
import os
files = os.listdir("c:/windows/system32")
for f in files:
if f.lower() == "msconfig.exe":
print(f)
在运行pythont1.py
之后,我什么也得不到。
为什么文件漏了?如何列出文件夹下的所有文件?
顺便说一下:我在Windows764bit下使用的是Python3.3.032bit版本
我不认为这是一个特定于Python的问题。在运行64位操作系统时,Windows确实有32位进程的有趣之处。在这种情况下,运行32位python时,Windows可能会将C:\ Windows\SysWOW64\的内容显示为system32。SysWOW64包含用于32位兼容层的各种Windows组件的32位版本。
以下是在Windows 7 x64系统上运行的;explorer.exe(在本例中是64位)肯定会显示这些文件夹的不同内容,但是:
在64位Windows上运行的32位进程具有可用于此问题的
sysnative
别名。见File System Redirector (MSDN),上面写着:
尝试:
C:\Windows\System32
而不是c:/windows/system32
相关问题 更多 >
编程相关推荐