Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.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 3.x Python3.X:rglob with FileNotFoundError:[WinError 3]系统找不到指定的路径_Python 3.x_List_Glob - Fatal编程技术网

Python 3.x Python3.X:rglob with FileNotFoundError:[WinError 3]系统找不到指定的路径

Python 3.x Python3.X:rglob with FileNotFoundError:[WinError 3]系统找不到指定的路径,python-3.x,list,glob,Python 3.x,List,Glob,我使用glob遍历一个目录,并提取符合特定参数的文件。我遇到的问题是,在glob的中途出现了FileNotFound错误: def collate_files(old_dir, new_dir) -> str: for subfolder in old_dir.rglob('*.xlsx'): if subfolder.match("string_title"): new_dir= new_dir.joinpath(subfolder)

我使用glob遍历一个目录,并提取符合特定参数的文件。我遇到的问题是,在glob的中途出现了FileNotFound错误:

def collate_files(old_dir, new_dir) -> str:
   for subfolder in old_dir.rglob('*.xlsx'):  
       if subfolder.match("string_title"):
           new_dir= new_dir.joinpath(subfolder)
           if Path.exists(new_dir):
               pass
           else:
               try:
                   shutil.copy(subfolder, new_dir, follow_symlinks=True)
               except OSError as e:
                   raise e
错误如下所示:

FileNotFoundError: [WinError 3] The system cannot find the path specified: "\\\\absoute_path_directory\\subfolder\\etc"

我仔细检查,文件路径存在。我该怎么做才能修复操作系统错误或完全忽略它?

这可能是您的文件路径长度的问题?常规DOS路径限制为最多260个字符。因此,您可以查看下面的链接以了解详细信息。最好的方法是在glob中激活长路径支持。但我不知道怎么做