How do I copy an entire directory of files into an existing directory using Python?
问题 Run the following code from a directory that contains a directory named bar (containing one or more files) and a directory named baz (also containing one or more files). Make sure there is not a directory named foo . import shutil shutil.copytree('bar', 'foo') shutil.copytree('baz', 'foo') It will fail with: $ python copytree_test.py Traceback (most recent call last): File "copytree_test.py", line 5, in <module> shutil.copytree('baz', 'foo') File "/System/Library/Frameworks/Python.framework