Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.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 WindowsError(3,‘系统找不到指定的路径’)_Python_Windows_Python 3.x - Fatal编程技术网

Python WindowsError(3,‘系统找不到指定的路径’)

Python WindowsError(3,‘系统找不到指定的路径’),python,windows,python-3.x,Python,Windows,Python 3.x,我有时会在下面的行中遇到以下异常: 在先前定义的路径中,总共有大约1956个pdf文件,其中43个被抛出异常。除此之外,我在路径和文件名中没有看到任何模式。 关于问题是什么有什么建议吗 totalBytes = 0 if pdfFile.endswith(".pdf") and \ (" permit " in pdfFile or " Permit " in pdfFile): filename = os.path.join(root, pdfFile) try:

我有时会在下面的行中遇到以下异常:

在先前定义的路径中,总共有大约1956个pdf文件,其中43个被抛出异常。除此之外,我在路径和文件名中没有看到任何模式。 关于问题是什么有什么建议吗

totalBytes = 0
if pdfFile.endswith(".pdf") and \
   (" permit " in pdfFile or " Permit " in pdfFile): 

    filename = os.path.join(root, pdfFile)
    try:
        absolutePath = os.path.abspath(filename)
        print ("absolutePath", absolutePath)
        # exception on this line, occasionally:
        numberOfBytes = os.path.getsize(absolutePath)
        print ("numberOfBytes", numberOfBytes)
        totalBytes += numberOfBytes
    except WindowsError as windowsError:
        print (windowsError, filename)

您应该能够通过一个奇怪的技巧绕过256个字符的限制:将\\?\前置到绝对文件名。当然,要避开那些斜杠:\\\?\\


另见:。TL;DR,以\\?\开头的名称使用不同的文件名解析器,具有不同的限制。

您应该能够通过一个奇怪的技巧绕过256个字符的限制:将\\?\前置到绝对文件名。当然,要避开那些斜杠:\\\?\\


另见:。TL;DR,以\\?\开头的名称使用不同的文件名解析器,但有不同的限制。

我在处理web2py中的一些代码时遇到了这种情况。多亏了你的回答,我才能够解决这个问题。我在处理web2py中的一些代码时遇到了这个问题。多亏了你的回答,我才得以解决。
totalBytes = 0
if pdfFile.endswith(".pdf") and \
   (" permit " in pdfFile or " Permit " in pdfFile): 

    filename = os.path.join(root, pdfFile)
    try:
        absolutePath = os.path.abspath(filename)
        print ("absolutePath", absolutePath)
        # exception on this line, occasionally:
        numberOfBytes = os.path.getsize(absolutePath)
        print ("numberOfBytes", numberOfBytes)
        totalBytes += numberOfBytes
    except WindowsError as windowsError:
        print (windowsError, filename)