encoding issue help

李洋 liyang1025 at gmail.com
Mon Apr 25 11:44:26 EDT 2016


hi:
  i want to decompress the string
 "\x1F\x8B\x08\x00\x00\x00\x00\x00\x00\x00UP]k\xC3 \x14\xFD+\xC3\xE7\xCD\xA8\xF9X\xE2\xEBX\xA1\x0CF\x1F\xBA\xEE%\x10\xAC\xB1\xAD\xC4h\x88f%\x8C\xFD\xF7]\x1B\xDA\xAD\xF8\xE29\xE7z\xEE9~#\xE7\x11G\xAF\xBB\x1C=\x22\xDFv_j\x04H+@\xBAW\x1A\xEEe\x91>SF\x18+i\x9Ef\x04\x84\xA1;\x02/]\x8F\xA5Q\xC2\xF6\xC2\x075\xE2\xFE8\x89\xB1m\xA4\x85\x89V\xFB\xC1\x88\x19\xA6\xDE\xB6\x1Fe\xB6y\x08\xCA\x87\xA7N\xCD\x1E\xC4^H\x10\xF6\x19'\x19/\x14g\x92K\xC1[\x06\xCA\xB2\x9Ca\x82K@\x07m\x8F\x17B\x98\xC1\xD7\xC9a2\xA6\xD9W\xA4j\xBAI\x9E\x84\xAB\x93\x7F\x80g\x18N\x9D,\xEB\xEA\x84fyJIAI\xCE'\xAF\xC6:\xB9\x0B\xE0\xF6\xDA\xA8\x95qg0\x8FE\x87Ke\x86iQbZU\x98\x924\xD6\x1C];\xC9\xB0n\xA3Jhd\x8C\x08\xB7\xCF\x1AN\xCE\xAA-|R\x94\xB3\x82\xA6\xE0\x902v\x19\xB4*l\xE7!*\x9F\xEB\xD5\x1A\x88\xB3>\xE8\xBF\x85\xC1u\xCA\x22n\xA1\x11\xA4\x99wj|\x17\x8B\x0F\x86\xF2\x8D\x8C\xE5\x85\x0Cn\x9Co\xDBt\xEF\xF5\xF2X\x1A\xADlx9\x09k\x95\xB9\x9A\xC8+DtI\xB0\xD116\xFA\xF9\x05\xBAs\xAET\xE0\x01\x00\x00"

this string is compress gzip if i save this string in  the file and read file  to decompress  that is not work ,otherwise  i use the python interpreter mode and paste the string in the command line the code is work

i suppose this is the character-set issue but i can't fix it !so i hope someone  give me a solution!
my cods blow ,and the work environment is linux 
import zlib

file_obj=open("compress_data.log","r+")

for gz_data in file_obj.readlines():

           print gz_data

           decompressed_data = zlib.decompress(gz_data, 16+zlib.MAX_WBITS)

           print decompressed_data



More information about the Python-list mailing list