"一首诗" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I didn't try your code. That might be working since it a completely
different method.
What mean is
pack works:
=========================
class POINT(Structure):
_fields_ = [('x', c_int), ('y', c_int)]
p = POINT(1,2) p.x, p.y (1, 2) str(buffer(p))
s = str(buffer(p))
=========================
unpack doesn't
=========================
p2 = POINT() ctypes.memmove(p2, s, ctypes.sizeof(POINT)) 14688904
p2.x, p2.y
=========================
I am not trying to parse data generated by a dll, but data received
from network.
That's also why I need Big Endian.
struct.unpack can do what you want as well:
import struct
data='\x01\x02\x03\x04\x11\x12\x13\x14\x21\x22\x23\x24\x31\x32\x33\x34\x41\x42\x43\x44'
[hex(a) for a in struct.unpack('>LLLLL',data)]
['0x1020304', '0x11121314', '0x21222324', '0x31323334', '0x41424344']
-Mark
--
http://mail.python.org/mailman/listinfo/python-list