from __future__ import print_function, division
import struct
num = -3333
raw = [(num & 0xff00)>>8, (num & 0xff)] # hi, lo
print('raw', raw)
print('raw byte 0:', raw[0])
print('raw byte 1:', raw[1])
data = bytearray(raw)
print('big endian:', data)
raw [242, 251] raw byte 0: 242 raw byte 1: 251 big endian: bytearray(b'\xf2\xfb')
ans = struct.unpack('>h', data)[0] # returns a tuple
print(ans)
(-3333,)
b = bytearray([23,123,55,234])
ans = struct.unpack('>hh', b)
print(ans)
(6011, 14314)
()