본문 바로가기
learning/Python

[Python] 파일압축 및 압축풀기

by 유자유자 2022. 6. 2.

[압축]
import shutil
shutil.make_archive(저장 경로 및 파일명, 'zip', 압축할 파일경로)
ex) shutil.make_archive('./zip_results', 'zip', './results/')

[압축해제]
dir_zip = '/home/datasets/test.zip'
dir_extract = '/home/datasets/test'

import zipfile
with zipfile.ZipFile(dir_zip, 'r') as zip_ref:
zip_ref.extractall(dir_extract)

'learning > Python' 카테고리의 다른 글

request 크롤링에 유용한 사이트 및 프로그램  (0) 2022.08.17
[Linux] 기타 코드  (0) 2022.06.22
[Python] directory  (0) 2022.06.03
[Python] GPU 제한  (0) 2022.04.15
[Linux] 파일 돌리기  (0) 2022.02.14

댓글