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 the byte format by using this method.
import zlib
s = b 'This is GFG author, and final year student.'
print ( len (s))
t = zlib.compress(s)
print ( len (t))
|
Output :
43
49
Example #2 :
import zlib
s = b 'GeeksForGeeks@12345678'
print ( len (s))
t = zlib.compress(s)
print ( len (t))
|
Output :
22
27
Last Updated :
06 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...