I am trying to decode binary data from a socket connection into python data types (ints, floats, etc.) using Struct. This is great for + 90% of cases. My problem is that some of the binary streams contain non-standard data types (e.g. 6 int bytes).
What I would like to do is to define a custom data type to handle these cases. In the following example, 'e' is my own 6-byte int
Team
struct.unpack('heH', binary_data)
will give:
(int_2b_var, int_6b_var, uint_2b_var)
How can i do this? Thanks
source
share