Python 解压缩文件(适用于Linux下)
适用于所有格式的压缩包
如: 7z(.7z)、ace(.ace)、alzip(.alz)、ar(.a)、arc(.arc)、arj(.arj), bzip2(.bz2)、cab(.cab)、compress(.z)、cpio(.cpio)、deb(.deb), DMS(.DMS)、GZIP(.gz)、LRZIP(.lrz)、LZH(.lha、.LZH)、LZIP(.lz), LZMA(.LZMA)、LZOP(.lzo)、RPM(.RPM)、RAR(.RAR)、RZIP(.rz), TAR(.TAR)、XZ(.XZ)、ZIP(.ZIP、.jar)和ZOO(.ZOO)
安装
pip install pyunpack
pip install patool
使用
解压
from pyunpack import Archive
Archive('zxp.rar').Archive('file_save_path')
压缩
def zip(self,dir):
import time, datetime
import shutil, os
Time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
print(Time)
shutil.make_archive(Time, "zip", dir)
pass
def unzip(self,zipfile):
import shutil, os
shutil.unpack_archive(zipfile)
pass