擅长:python、mysql、java
<p>从上的文档os.步行地址:</p>
<blockquote>
<p>dirpath is a string, the path to the directory. dirnames is a list of the names of the subdirectories in dirpath (excluding '.' and '..'). filenames is a list of the names of the non-directory files in dirpath. Note that the names in the lists contain no path components. To get a full path (which begins with top) to a file or directory in dirpath, do os.path.join(dirpath, name).</p>
</blockquote>
<p>所以你的代码应该是这样的:</p>
<pre><code>import os
from shutil import copyfile
path = "videos/"
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith((".mp4", ".mp4")):
print(name)
src = os.path.join(root, name)
copyfile(src, dst)
</code></pre>