資料壓縮與保存¶
本章中描述的模組支援使用 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 archivesBadZipFile
BadZipfile
LargeZipFile
ZipInfo
is_zipfile()
ZIP_STORED
ZIP_DEFLATED
ZIP_BZIP2
ZIP_LZMA
- ZipFile 物件
- Path Objects
- PyZipFile 物件
- ZipInfo 物件
ZipInfo.from_file()
ZipInfo.is_dir()
ZipInfo.filename
ZipInfo.date_time
ZipInfo.compress_type
ZipInfo.comment
ZipInfo.extra
ZipInfo.create_system
ZipInfo.create_version
ZipInfo.extract_version
ZipInfo.reserved
ZipInfo.flag_bits
ZipInfo.volume
ZipInfo.internal_attr
ZipInfo.external_attr
ZipInfo.header_offset
ZipInfo.CRC
ZipInfo.compress_size
ZipInfo.file_size
- Command-Line Interface
- Decompression pitfalls
tarfile
--- Read and write tar archive filesopen()
is_tarfile()
TarError
ReadError
CompressionError
StreamError
ExtractError
HeaderError
FilterError
AbsolutePathError
OutsideDestinationError
SpecialFileError
AbsoluteLinkError
LinkOutsideDestinationError
ENCODING
REGTYPE
AREGTYPE
LNKTYPE
SYMTYPE
CHRTYPE
BLKTYPE
DIRTYPE
FIFOTYPE
CONTTYPE
GNUTYPE_LONGNAME
GNUTYPE_LONGLINK
GNUTYPE_SPARSE
USTAR_FORMAT
GNU_FORMAT
PAX_FORMAT
DEFAULT_FORMAT
- TarFile 物件
- TarInfo 物件
TarInfo
TarInfo.frombuf()
TarInfo.fromtarfile()
TarInfo.tobuf()
TarInfo.name
TarInfo.size
TarInfo.mtime
TarInfo.mode
TarInfo.type
TarInfo.linkname
TarInfo.uid
TarInfo.gid
TarInfo.uname
TarInfo.gname
TarInfo.pax_headers
TarInfo.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