일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 다중 서버 명령
- instance
- Express
- proguard
- Modulization
- Android
- event-driven
- node
- OOP
- Mongo
- API테스트
- Java
- centos
- multidex
- 64k method
- Setup
- ssh key
- elemMatch
- Linux
- react-native
- Mongoose
- iIntelliJ
- PBKDF2
- Git
- pbkdf2-password
- window
- memory structure
- MEAN stack
- MaridDB
- rest-assured
Archives
- Today
- Total
천줄코딩도 한 걸음부터
Python Zip 파일로 압축하기 본문
이 문서는 아래 링크의 문서를 참조하였습니다.
Python Zipfile Documentation : https://docs.python.org/3/library/zipfile.html
import os
import zipfile
'''
class zipfile.ZipFile(파일주소, Mode(Option))
Mode :
'r' 존재하는 파일 읽기
'w' 파일이 존재하면 지우고 생성
'a' 존재하는 파일에 append 하기
'x' 파일이 존재하지 않으면 생성, 존재하면 FileExistsError 뱉음
'''
zip = zipfile.ZipFile('c:\\python\\archive.zip', 'w')
for folder, subfolders, files in os.walk('C:\\python\\folder'):
for file in files:
zip.write(os.path.join(folder, file), # 파일 이름
os.path.relpath(os.path.join(folder, file), 'C:\\python\\folder'), # 압축 파일의 이름(Default : 파일 이름과 같음)
compress_type = zipfile.ZIP_DEFLATED) # 압축 타입
zip.close()
'Others' 카테고리의 다른 글
Node.js Mysql(MariaDB) 모듈화하기 (1) | 2018.05.14 |
---|---|
Node.js 대상 디렉토리 내의 모든 파일 읽어오기 (2) | 2017.11.09 |
Node.js Crypto 사용하여 파일로부터 Hash값 얻어오기 (0) | 2017.11.09 |
Python input() 와 raw_input() 그리고 print 와 print() (0) | 2017.10.18 |
Access restriction: The type 'OOO' is not API ... 에러 (0) | 2017.10.16 |