Need Help - Bitfield Conversion
I want to convert strings to bit fields. Also, convert them to binary and then use. Need help with this .. help me ..
-3
user46646
source
to share
2 answers
I think the struct module is what you need.
Usage example:
>>> from struct import *
>>> pack('hhl', 1, 2, 3)
'\x00\x01\x00\x02\x00\x00\x00\x03'
>>> unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03')
(1, 2, 3)
>>> calcsize('hhl')
8
+2
Greg
source
to share
they are all binary already ... What language do we speak?
I would start by looking at the string as an array of characters and working with each character individually.
0
Cogsy
source
to share