資料壓縮與保存¶
本章中描述的模組支援使用 zlib、gzip、bzip2 和 lzma 演算法進行資料壓縮,以及建立 ZIP 和 tar 格式的存檔。另請參閱 shutil 模組提供的 Archiving operations。
zlib--- 相容於 gzip 的壓縮gzip--- gzip 檔案的支援bz2--- Support for bzip2 compressionlzma--- Compression using the LZMA algorithmzipfile--- Work with ZIP archivesBadZipFileBadZipfileLargeZipFileZipInfois_zipfile()ZIP_STOREDZIP_DEFLATEDZIP_BZIP2ZIP_LZMA- ZipFile 物件
- Path Objects
- 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
- Command-Line Interface
- Decompression pitfalls
tarfile--- Read and write tar archive filesopen()is_tarfile()TarErrorReadErrorCompressionErrorStreamErrorExtractErrorHeaderErrorFilterErrorAbsolutePathErrorOutsideDestinationErrorSpecialFileErrorAbsoluteLinkErrorLinkOutsideDestinationErrorENCODINGREGTYPEAREGTYPELNKTYPESYMTYPECHRTYPEBLKTYPEDIRTYPEFIFOTYPECONTTYPEGNUTYPE_LONGNAMEGNUTYPE_LONGLINKGNUTYPE_SPARSEUSTAR_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.replace()TarInfo.isfile()TarInfo.isreg()TarInfo.isdir()TarInfo.issym()TarInfo.islnk()TarInfo.ischr()TarInfo.isblk()TarInfo.isfifo()TarInfo.isdev()
- Extraction filters
- Command-Line Interface
- 範例
- Supported tar formats
- Unicode issues