Python Programming - Standard Libraries - Discussion

Discussion Forum : Standard Libraries - General Questions (Q.No. 84)
84.
What is the purpose of the gzip module?
Sorting elements in a list
Handling exceptions and errors
Compressing and decompressing files using the gzip format
Parsing JSON data
Answer: Option
Explanation:
import gzip

# Example usage of gzip module for compressing a file
with open('file.txt', 'rb') as f_in:
    with gzip.open('file.txt.gz', 'wb') as f_out:
        f_out.writelines(f_in)
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.