gzip.compress(s) in Python Last Updated : 23 Mar, 2020 Comments Improve Suggest changes Like Article Like Report 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 the byte format by using this method. Python3 1=1 # import gzip and compress import gzip s = b'This is GFG author, and final year student.' print(len(s)) # using gzip.compress(s) method t = gzip.compress(s) print(len(t)) Output : 43 61 Example #2 : Python3 1=1 # import gzip and compress import gzip s = b'GeeksForGeeks@12345678' print(len(s)) # using gzip.compress(s) method t = gzip.compress(s) print(len(t)) Output : 22 39 Comment More infoAdvertise with us Next Article gzip.compress(s) in Python J Jitender_1998 Follow Improve Article Tags : Python Python-gzip Practice Tags : python Similar Reads 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 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 zlib.compress(s) in python 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 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 numpy.compress() in Python The numpy.compress() function returns selected slices of an array along mentioned axis, that satisfies an axis. Syntax: numpy.compress(condition, array, axis = None, out = None) Parameters : condition : [array_like]Condition on the basis of which user extract elements. Applying condition on input_ar 2 min read Like