Compress and decompress string in Python

0 votes
Please write a program to compress and decompress the string. Which module should be used?
Jul 23, 2019 in Python by Ritu

1 answer to this question.

0 votes

You can use the zlib module available in python to compress and decompress the string. Refer to the code below:

import zlib
text="Hello world"
print("Compressed: ", comp)
print("Decompressed: ", decomp)

This should work.

To know more, It's recommended to join our Python Training in Chennai today.

answered Jul 23, 2019 by Bhagavath

edited Oct 7 by Sarfaraz

Related Questions In Python

0 votes
1 answer

How can I print variable and string on same line in Python?

Use , to separate strings and variables while printing: print ...READ MORE

answered Sep 17, 2018 in Python by Priyaj
• 58,140 points
0 votes
1 answer

Is it possible to print a string and a variable in a single print statement in Python?

This can be done using simple string ...READ MORE

answered Jul 15, 2019 in Python by Neel
• 3,020 points
+1 vote
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,421 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
+1 vote
1 answer

Python: Print variable and string in same line

For a better understanding you can refer ...READ MORE

answered Oct 30, 2018 in Python by Priyaj
• 58,140 points
0 votes
1 answer

Replace First and Last Word of String in the Most Pythonic Way

import re a = " this is a ...READ MORE

answered Aug 23, 2018 in Python by aryya
• 7,440 points