Dernière activité 10 months ago

這段 Python 程式碼使用 brotli 模組來 壓縮與解壓縮資料。它先將 字串資料 (data) 進行 Brotli 壓縮,然後再解壓縮回原始內容,並分別輸出 壓縮後與解壓縮後的結果。Brotli 是由 Google 開發的高效能壓縮演算法,適用於 網頁資源最佳化(如 HTML、CSS、JavaScript 壓縮)、檔案儲存與傳輸最佳化,提高 傳輸速度並減少頻寬消耗。

timmy a révisé ce gist 10 months ago. Aller à la révision

Aucun changement

timmy a révisé ce gist 10 months ago. Aller à la révision

Aucun changement

timmy a révisé ce gist 1 year ago. Aller à la révision

1 file changed, 15 insertions

brotli_compression_example.py(fichier créé)

@@ -0,0 +1,15 @@
1 + import brotli
2 +
3 + # 原始資料
4 + data = b"This is a test. This is only a test."
5 +
6 + # 壓縮資料
7 + compressed = brotli.compress(data)
8 +
9 + print("Compressed data:", compressed)
10 +
11 + # 解壓縮資料
12 + decompressed = brotli.decompress(compressed)
13 +
14 + print("Decompressed data:", decompressed)
15 +
Plus récent Plus ancien