Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

gzip.decompress(s) in Python

  • Last Updated : 26 Mar, 2020

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.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Example #1 :
In this example we can see that by using gzip.decompress(s) method, we are able to decompress the compressed string in the byte format of string by using this method.






# import gzip and decompress
import gzip
s = b'This is GFG author, and final year student.'
s = gzip.compress(s)
  
# using gzip.decompress(s) method
t = gzip.decompress(s)
print(t)

Output :

b’This is GFG author, and final year student.’

Example #2 :




# import gzip and compress
import gzip
s = b'GeeksForGeeks@12345678'
s = gzip.compress(s)
  
# using gzip.decompress(s) method
t = gzip.decompress(s)
print(t)

Output :

b’GeeksForGeeks@12345678′

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!