Development/Python
[Python] 특정 디렉토리 복사 붙여넣기 (Copy & Paste)
성딱이
2022. 2. 9. 18:08
반응형
방법
shutil.copytree(target_path, destination_path)
예시
import shutil
target_path = '/saranghaeyo/yeonyegajungye'
destination_path = '/saranghaeyo/komawaryo'
shutil.copytree(target_path, destination_path)
# 붙여넣기 하고자 하는 디렉토리가 이미 존재하는 경우 (Python 3.8 이상부터 가능)
shutil.copytree(target_path, destination_path, dirs_exist_ok=True)
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
stackoverflow.com
반응형