Compress Decompress Strings

Question:

Write a program to compress and decompress the string “Global SQA!Global SQA!Global SQA!Global SQA!Global SQA!Global SQA!”

Use zlib.compress() and zlib.decompress() to compress and decompress a string.

Program:

Explanation:

zlib.compressobj([level[, method[, wbits[, memlevel[, strategy]]]]])

Returns a compression object, to be used for compressing data streams that won’t fit into memory at once.

zlib.decompress(string[wbits[bufsize]])

Decompresses the data in string, returning a string containing the uncompressed data.

Output:

Do share your feedback in comments to help us adding more programs like this.

Checkout more Python Programs

Click here

Leave a Reply