copapy.unpack#

copapy.unpack(fmt, data, offset=0)#

Convert bytes to int and float values, like struct.unpack_from.

The format is described at pack. Unsigned 32 bit fields (‘I’) are returned as int, values above 2**31 - 1 are therefore negative.

Parameters:
  • fmt (str) – Format string, e.g. ‘<Hhf’

  • data (Sequence[value[int] | int] | array[int]) – Bytes as ints or copapy int values from 0 to 255, e.g. the result of pack or a byte array

  • offset (int) – Index of the first byte in data

Return type:

tuple[Any, ...]

Returns:

Tuple with one copapy value per field, numbers if all its bytes are numbers