问题
I need a function in python that lets me specify the source and destination paths for a folder and copies the source folder recursively into the destination folder. The implementation I am looking for needs to be platform independent
回答1:
You could use shutil.copytree:
shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False)
Recursively copy an entire directory tree rooted at src, returning the destination directory. The destination directory, named by dst, must not already exist; it will be created as well as missing parent directories. Permissions and times of directories are copied with copystat(), individual files are copied using shutil.copy2().
import shutil
shutil.copytree(src, dst)
来源:https://stackoverflow.com/questions/27592258/how-do-i-copy-a-folder-and-its-contents-files-subdirectories-in-python-with-pl