Adam Kubica a écrit : > After some king of brain fucked tries, I found: > > zlib.decompress( data ) #equivalent gzdecompress() > zlib.decompress( data, -zlib.MAX_WBITS ) #equivalent gzdeflate()
Note: you can also use encode() and decode() methods on the string containing your data, specifying 'zip' as encoding. Example: >>> s="Hello"*100 >>> s1 = s.encode('zip') >>> len(s1) 18 >>> s1 'x\x9c\xf3H\xcd\xc9\xc9\xf7\x18%F\x12\x01\x00\t\xb9\xc3Q' >>> s2 = s1.decode('zip') >>> len(s2) 500 >>> s2 'HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHell oHelloHelloHelloHello' >>> IMHO this is mode understandable than zlib.decompress( data, -zlib.MAX_WBITS ). A+ Laurent. PS. There may be other compression encodings... look at encodings.aliases.aliases, where I can see 'zip' and 'zlib' (same), but also 'bz2'. - you can also found encoders for hexadecimal, quoted printable, and other formats. -- http://mail.python.org/mailman/listinfo/python-list