Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
os 模組
|
339
zlib 模組
zlib
模組能讓 Python 程式使用免費的 InfoZip
zlib
壓縮程式庫(
http://www.
info-zip.org/pub/infozip/
1.1.4 或之後版本。
zlib
由模組
gzip
zipfile
用,但也能直接用於任何特殊的壓縮需求。
zlib
所提供的最常用的函式
有:
compress compress(s, level=6)
壓縮字串
s
並回傳經過壓縮的資料所成的字串。
level
是介於
1
9
之間
的一個整數:
1
請求一般的壓縮,但作業速度會比較快,而
9
請求最佳的
壓縮,但會耗費更多的計算成本。
decompress decompress(s)
解壓縮經過壓縮的 bytestring
s
,並回傳未壓縮的資料所成的 bytestring
(也接受選擇性的引數用於相當進階的功能,參閱線上文件(https://docs.
python.org/3/library/zlib.html?highlight=zlib#zlib.decompress))。
zlib
模組也提供函式用來計算 CRCCyclic-Redundancy Check,循環冗
餘校驗),它能用來偵測壓縮過的資料和要壓縮的物件中的毀損,並能夠
漸進式地解壓縮資料,以處理太大無法一次放入記憶體中的資料流。對於
這種進階的功能性,請查閱 Python 程式庫的線上文件(
https://docs.python.
org/3/library/zlib.html
)。
os 模組
os
是一個集成模組
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819