bz2

The bz2 module is used to read and write data compressed according to the bzip2 compression algorithm.

BZ2File(filename [, mode [, buffering [, compresslevel]]])

Opens a .bz2 file, filename, and returns a file-like object. mode is 'r' for reading or 'w' for writing. Universal newline support is also available by specifying a mode of 'rU'. buffering specifies the buffer size in bytes with a default value of 0 (no buffering). compresslevel is a number between 1 and 9. A value of 9 (the default) provides the highest level of compression, but consumes the most processing time. The returned object supports all the common file operations, including close(), read(), readline(), readlines(), seek(), tell(), write(), and writelines().

 BZ2Compressor([ ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.