Python IsDirectoryError:[Errno 21]是一个目录:
我试图在我的输出文件夹中写入一个新文件,但我不断收到一个错误,错误是“isDirectoryError:[Errno 21]是一个目录:'Output/” 当我使用:Python IsDirectoryError:[Errno 21]是一个目录:,python,directory,Python,Directory,我试图在我的输出文件夹中写入一个新文件,但我不断收到一个错误,错误是“isDirectoryError:[Errno 21]是一个目录:'Output/” 当我使用: outputFile = os.path.join(outputFilePath, Path(inFilePath).stem + "-" + new ) 它起作用了,但是,当我使用: outputFile = outputFilePath 我特别尝试使用第二个参数,因为在我的主函数中,我传入了3个参
outputFile = os.path.join(outputFilePath, Path(inFilePath).stem + "-" + new )
它起作用了,但是,当我使用:
outputFile = outputFilePath
我特别尝试使用第二个参数,因为在我的主函数中,我传入了3个参数(InputFilePath、OutputFilePath、Num)“在管道中,因此它必须保留该名称。它在我以前编写的程序中工作,所以我不知道为什么它现在不工作。好吧,您的错误消息指出输出路径是目录,而不是文件,因此您必须修复它。在您的程序中,这些变量的可能值是什么?仅凭这些片段很难做出判断。