import os,shutil path = r"/data/wangyh/data4/Datasets/shadow/video_new/visha2/test/images"# 文件夹路径 des = r"/data/wangyh/data4/video_shadow_detection/segment3/video" for _dirin os.listdir(des): b = os.path.join(des, _dir, "images") if os.path.exists(b): # 需要检查目标路径是否存在相应文件夹 shutil.rmtree(b) shutil.copytree(path, b) #复制文件夹到默认路径