Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python和Windows 10最大路径长度_Python_Windows - Fatal编程技术网

Python和Windows 10最大路径长度

Python和Windows 10最大路径长度,python,windows,Python,Windows,Python2.7.4中是否有一个设置可以在Windows 10上启用长文件名处理 在Computer\HKEY\u LOCAL\u MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem下的注册表中,我看到LongPathsEnabled的标志设置为1或true 我发现我能够将一个文件从创建总路径长度超过260的CMD shell复制到一个新位置 但在python 2.7脚本中,当试图打开一个路径过长的文件进行写入时,会出现以下错误: error

Python2.7.4中是否有一个设置可以在Windows 10上启用长文件名处理

在Computer\HKEY\u LOCAL\u MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem下的注册表中,我看到LongPathsEnabled的标志设置为1或true

我发现我能够将一个文件从创建总路径长度超过260的CMD shell复制到一个新位置

但在python 2.7脚本中,当试图打开一个路径过长的文件进行写入时,会出现以下错误:

error in write
    file = open(path, 'w')
IOError: [Errno 2] No such file or directory: "c:\\..."

这可能是其他一些问题,但创建路径长度较短的文件似乎工作正常。

必须在系统级别和应用程序清单中启用长路径。如果您可以升级,它将为Python3.6+启用。否则,您可以修改“python.exe”中嵌入的清单。但是,如果您正在编写需要在Windows 7和8中运行的脚本,则不应使用此新的长路径功能。改用\\?\(扩展设备)路径。它必须是Unicode、完全限定的,并且只使用反斜杠作为路径分隔符。在这种情况下,UNC路径(例如
r“\\server\share\file”
)应使用“UNC”设备(例如
r“\\?\UNC\server\share\file”
)。