[BangPypers] binary file unpacking

murugadoss murugadoss2884 at gmail.com
Tue Jun 1 09:27:42 CEST 2010


Hi,
I am trying to unpack a binary file,

        rfile = open(filename,'rb')
        print "file Size", os.path.getsize(filename)
        text = rfile.read()
         print "Text", text
        while(text != 'EOF'):
                text = struct.unpack("!c",text)
                Message  = Message + struct.pack("!c",text)
                text = rfile.read()

Output:
file Size 112
Text 킶
}v/◇+1h?
   w#?'?CF
              ?V


Error:
error: unpack requires a string argument of length 1


Can anyone please tell me, the way to unpack the binay data from the file.

If the questions is very basic.I kindly apologize for it. I am not able to
get through it

Kindly help me
--
Thanks & Regards
V.Murugadoss


More information about the BangPypers mailing list