我写下了这段代码:
import shutil
files = os.listdir(path, path=None)
for d in os.listdir(path):
for f in files:
shutil.move(d+f, path)
Run Code Online (Sandbox Code Playgroud)
我希望给定目录 ( path)中的每个文件夹都包含文件,将该文件夹中包含的文件移动到包含该文件夹的主目录 ( path) 中。
例如:此文件夹中的文件: C:/example/subfolder/
将被移入: C:/example/
(并且该目录将被删除。)对不起,我的英语不好:)