【发布时间】:2015-11-20 14:21:18
【问题描述】:
这里是sn-p:
p = r"\\server\folder1\folder2"
print p
files = os.listdir(p)
print "found files: ", len(files)
32位机器上的输出:
\\server\folder1\folder2
found files: 9818
64位机器上的输出:
\\server\folder1\folder2
found files: 9818
或
\\server\folder1\folder2
<type 'exceptions.WindowsError'> [Error 24] The program issued a command but the command length is incorrect: '\\\\server\\folder1\\folder2/*.*'
我试过了 - Python 2.5、2.7、32 位和 64 位(在 64 位机器上)。 - 机器有 32 位和 64 位。
网络共享是可访问的,我有读/写权限。
任何人都知道为什么会引发错误仅在 64 位机器上???
谢谢, r
【问题讨论】:
-
或许系统调用状态码会更有帮助。安装Debugging Tools for Windows。为调试符号设置系统环境变量:
_NT_SYMBOL_PATH=symsrv*symsrv.dll*C:\Symbols*http://msdl.microsoft.com/download/symbols。使用-i运行您的脚本。在调试器中附加到 python.exe。在系统调用上设置断点:bp ntdll!NtQueryDirectoryFile; g。在 Python 中,调用os.listdir(p)。在调试器中输入pt; r rax以单步执行函数返回并打印状态码。输入g继续。 -
谢谢!我会试一试的。
-
您也可以尝试以下操作,而无需使用调试器。初始设置:
import ctypes;ntdll = ctypes.WinDLL('ntdll');ntdll.RtlGetLastNtStatus.restype = ctypes.c_uint。然后在处理异常的except块中,您可以设置ntstatus = hex(ntdll.RtlGetLastNtStatus())。
标签: python windows 64-bit 32bit-64bit