<p>因此,我有一个目录,其中有几个子目录,我试图遍历所有的子目录(每个子目录中都有一堆文件,我正在将这些文件拆分成更小的文件)。我一直在尝试使用<code>os.listdir</code>,但我一直收到这样的错误FileNotFoundError:[Errno 2]没有这样的文件或目录:“mFAPA”</p>
<p>这个子目录肯定存在,所以我不确定为什么会发生这种情况</p>
<pre><code>for dir in os.listdir('../conv_files'):
for filename in os.listdir(dir):
</code></pre>
<p>我试图使用for循环遍历每个目录,然后在每个目录中遍历每个文件。错误出现在代码的第二行,一旦它位于父目录中,由于某种原因,它就无法执行<code>for filename in os.listdir(dir)</code>部分。有什么建议吗</p>