반응형
방법
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
반응형
'Development > Python' 카테고리의 다른 글
[Python] Flask API Test를 curl로 진행 시 timeout(28) 오류 & NoneType Error 해결 (0) | 2022.03.15 |
---|---|
[Python] Pandas DataFrame 혹은 Series에서 문자열 조건 결과 얻기(str.contains) (0) | 2022.02.09 |
[Python] Dictionary의 Value를 얻을 때, 존재하지 않는 Key는 넘어가야 하는 경우(KeyError 해결) (0) | 2022.02.09 |
[Python] ' is None ' 과 ' == None ' 의 차이점 (4) | 2022.01.28 |
[Python] 리스트의 첫 번째 순서로 Append 하는 방법 (0) | 2022.01.20 |
댓글