python compress/decompress file

Reference

http://docs.python.org/3/library/shutil.html#module-shutil

Description

把 d:/nginx-1.4.3 壓縮到 d:/ziptarget/test.zip
再把 d:/ziptarget/test.zip 解壓縮到 d:/unziptarget/

Codes (適合 python 3.2 以上)

import shutil

unzipfile_folder = 'd:/unziptarget'
archive_name = 'd:/ziptarget/test'
root_dir = 'd:/nginx-1.4.3'
archive_path = shutil.make_archive(archive_name, 'zip', root_dir)
shutil.unpack_archive(archive_path, unzipfile_folder)

沒有留言:

張貼留言

Lessons Learned While Benchmarking vLLM with GPU

Recently, I benchmarked vLLM on a GPU to better understand how much throughput can realistically be expected in an LLM serving setup. One ...