数据压缩和存档¶
本章中描述的模块支持 zlib、gzip、bzip2 和 lzma 数据压缩算法,以及创建 ZIP 和 tar 格式的归档文件。参见由 shutil 模块提供的 归档操作 。
zlib--- 与 gzip 兼容的压缩gzip--- 对 gzip 格式的支持bz2--- 对 bzip2 压缩算法的支持lzma--- 用 LZMA 算法压缩zipfile--- 使用ZIP存档BadZipFileBadZipfileLargeZipFileZipInfois_zipfile()ZIP_STOREDZIP_DEFLATEDZIP_BZIP2ZIP_LZMA- ZipFile 对象
- Path 对象
- PyZipFile 对象
- ZipInfo 对象
ZipInfo.from_file()ZipInfo.is_dir()ZipInfo.filenameZipInfo.date_timeZipInfo.compress_typeZipInfo.commentZipInfo.extraZipInfo.create_systemZipInfo.create_versionZipInfo.extract_versionZipInfo.reservedZipInfo.flag_bitsZipInfo.volumeZipInfo.internal_attrZipInfo.external_attrZipInfo.header_offsetZipInfo.CRCZipInfo.compress_sizeZipInfo.file_size
- 命令行接口
- 解压缩的障碍
tarfile--- 读写tar归档文件open()is_tarfile()TarErrorReadErrorCompressionErrorStreamErrorExtractErrorHeaderErrorFilterErrorAbsolutePathErrorOutsideDestinationErrorSpecialFileErrorAbsoluteLinkErrorLinkOutsideDestinationErrorENCODINGUSTAR_FORMATGNU_FORMATPAX_FORMATDEFAULT_FORMAT- TarFile 对象
- TarInfo 对象
TarInfoTarInfo.frombuf()TarInfo.fromtarfile()TarInfo.tobuf()TarInfo.nameTarInfo.sizeTarInfo.mtimeTarInfo.modeTarInfo.typeTarInfo.linknameTarInfo.uidTarInfo.gidTarInfo.unameTarInfo.gnameTarInfo.pax_headersTarInfo.isfile()TarInfo.isreg()TarInfo.isdir()TarInfo.issym()TarInfo.islnk()TarInfo.ischr()TarInfo.isblk()TarInfo.isfifo()TarInfo.isdev()
- 解压缩过滤器
- 命令行接口
- 例子
- 受支持的 tar 格式
- Unicode 问题