How to copy a folder and its contents (files / subdirectories) in Python using a platform independent implementation

I need a function in python that allows me to specify the source and destination path for a folder and recursively copy the source folder to the destination folder. The implementation I'm looking for should be platform independent.

+4
source share
1 answer

You can use shutil.copytree :

shutil.copytree (src, dst, symlinks = False, ignore = None, copy_function = copy2, ignore_dangling_symlinks = False)

, src, . , dst, ; , . copystat(), shutil.copy2().


import shutil
shutil.copytree(src, dst)
+8

Source: https://habr.com/ru/post/1568539/


All Articles