flip bytes using Python's struct module -
I want to flip from this string to a slightly higher end:
\ x00 \ X40
To make it like this:
\ x40 \ x00
I think use Struct.pack will have the proper function to do, but I can not find a way to work it properly.
Thanks
You are not showing the whole code, then the easiest solution would be :
data = data [1] + data [0]
If you have structure
:
& gt; & Gt; & Gt; From the composition import pack, unpack & gt; & Gt; & Gt; Unpack ('& lt; H', '\ x12 \ x13') (4882,) & gt; & Gt; & Gt; Packs ('& gt; H', * unpack ('' 'H', '\ x12 \ x13')) '\ x13 \ x12'
Which string is a bit In unpacked -Andende unsigned miniature, and then pack it back into the big endian unsigned miniature. You can take it the other way around, of course. If you change between BE and LE, it does not matter how you are converting - the conversion function is bi-directional.
Comments
Post a Comment