Open In App

bz2.decompress(s) in Python

Last Updated : 26 Mar, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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 are able to decompress the compressed string in the byte format of string by using this method. Python3 1=1
# import bz2 and decompress
import bz2

s = b'This is GFG author, and final year student.'
s = bz2.compress(s)

# using bz2.decompress(s) method
t = bz2.decompress(s)
print(t)
Output :
b'This is GFG author, and final year student.'
Example #2 : Python3 1=1
# import bz2 and compress
import bz2

s = b'GeeksForGeeks@12345678'
s = bz2.compress(s)

# using bz2.decompress(s) method
t = bz2.decompress(s)
print(t)
Output :
b'GeeksForGeeks@12345678'

Next Article
Article Tags :
Practice Tags :

Similar Reads