zlib.compress(s) in python Last Updated : 06 Mar, 2020 Comments Improve Suggest changes Like Article Like Report With the help of zlib.compress(s) method, we can get compress the bytes of string by using zlib.compress(s) method. Syntax : zlib.compress(string) Return : Return compressed string. Example #1 : In this example we can see that by using zlib.compress(s) method, we are able to compress the string in the byte format by using this method. Python3 1=1 # import zlib and compress import zlib s = b'This is GFG author, and final year student.' print(len(s)) # using zlib.compress(s) method t = zlib.compress(s) print(len(t)) Output : 43 49 Example #2 : Python3 1=1 # import zlib and compress import zlib s = b'GeeksForGeeks@12345678' print(len(s)) # using zlib.compress(s) method t = zlib.compress(s) print(len(t)) Output : 22 27 Comment More infoAdvertise with us Next Article zlib.compress(s) in python J Jitender_1998 Follow Improve Article Tags : Python Python-Miscellaneous python-zlib Practice Tags : python Similar Reads zlib.decompress(s) in Python With the help of zlib.decompress(s) method, we can decompress the compressed bytes of string into original string by using zlib.decompress(s) method. Syntax : zlib.decompress(string) Return : Return decompressed string. Example #1 : In this example we can see that by using zlib.decompress(s) method, 1 min read bz2.compress(s) in Python With the help of bz2.compress(s) method, we can get compress the bytes of string by using bz2.compress(s) method. Syntax : bz2.compress(string) Return : Return compressed string. Example #1 : In this example we can see that by using bz2.compress(s) method, we are able to compress the string in the b 1 min read gzip.compress(s) in Python With the help of gzip.compress(s) method, we can get compress the bytes of string by using gzip.compress(s) method. Syntax : gzip.compress(string) Return : Return compressed string. Example #1 : In this example we can see that by using gzip.compress(s) method, we are able to compress the string in t 1 min read bz2.decompress(s) in Python With the help of bz2.decompress(s) method, we can decompress the compressed bytes of string into original string by using bz2.decompress(s) method. Syntax : bz2.decompress(string) Return : Return decompressed string. Example #1 : In this example we can see that by using bz2.decompress(s) method, we 1 min read gzip.decompress(s) in Python With the help of gzip.decompress(s) method, we can decompress the compressed bytes of string into original string by using gzip.decompress(s) method. Syntax : gzip.decompress(string) Return : Return decompressed string. Example #1 : In this example we can see that by using gzip.decompress(s) method, 1 min read Like