decompress_log.py 377 B

12345678910111213141516
  1. import zlib
  2. def decompress_zlib(src, dst):
  3. src = open(src, "rb+")
  4. dst = open(dst, "wb+")
  5. handler = zlib.decompressobj(-zlib.MAX_WBITS)
  6. data = src.read(1024)
  7. while data:
  8. dst.write(handler.decompress(data))
  9. data = src.read(1024)
  10. dst.write(str(handler.flush))
  11. if __name__ == "__main__":
  12. decompress_zlib("2021-04-15-zap","test.log")