从长路径提取文件时,Windows上的Python Zipfile extractall IOError

Att*_*tti 2 python zipfile windows-7

我正在运行python zipfile extractall,将其解压缩到长度超过255个字符的路径。在Windows 7 64bit上运行。我要跟踪以下错误[Errno 2] No such file or directory: u'

有任何想法吗 ?

我要从中提取的网络文件夹。因此,我将该文件夹安装为网络驱动器t:\,这暂时解决了该问题。

use*_*026 5

这为我工作:

class ZipfileLongPaths(zipfile.ZipFile):

    def _extract_member(self, member, targetpath, pwd):
        targetpath = winapi_path(targetpath)
        return zipfile.ZipFile._extract_member(self, member, targetpath, pwd)
Run Code Online (Sandbox Code Playgroud)

其中winapi_path是:

def winapi_path(dos_path, encoding=None):
    path = os.path.abspath(dos_path)

    if path.startswith("\\\\"):
        path = "\\\\?\\UNC\\" + path[2:]
    else:
        path = "\\\\?\\" + path 

    return path  
Run Code Online (Sandbox Code Playgroud)

路径名获取的winapi_path 时间太长,无法打开?