Reputation: 11532
I converted unsigned long from c++ to eight bytes and send over network(0 position is the least significant). How to convert on python side this eight bytes to number ( unsigned long)?
Upvotes: 1
Views: 486
Reputation: 1121962
Use the struct
module:
import struct
struct.unpack('Q', data)
Do carefully study the module documentation; the format 'Q'
means 'unsigned long long', which has a standard size of 8 bytes. You can add a flag to indicate byte-order and alignment behaviour. Without a flag native byte order is assumed, use <
or >
to signify little or big endian byte ordering for example.
Upvotes: 2