import shutil import os #目录自己改一下即可,复制 path = "./static/imgs/" new_path = "./static/upload/" for file in os.listdir(path): full_file = os.path.join(path, file) new_full_file = os.path.join(new_path, file) shutil.copy(full_file, new_full_file) # 删除目录,在新建相同目录 shutil.rmtree(path) os.mkdir(path)