首页 > 解决方案 > IsADirectoryError: [Errno 21] 是一个目录:

问题描述

我正在尝试在我的输出文件夹中写入一个新文件,但我不断收到错误消息“IsADirectoryError:[Errno 21] 是一个目录:'Output/'。

当我使用:

 outputFile = os.path.join(outputFilePath, Path(inFilePath).stem + "-" + new ) 

它有效,但是,当我使用时它不起作用:

 outputFile = outputFilePath

我特别尝试使用第二个,因为在我的主函数中我传入了 3 个参数(InputFilePath、OutputFilePath、Num)。我将在管道中调用“OutputFilePath”,因此它必须保留该名称。它适用于我以前编写的程序,所以我不知道为什么它现在不起作用。

标签: pythondirectory

解决方案


推荐阅读