def unpack(fmt, data):
    """
    Return struct.unpack(fmt, data) with the optional single * in fmt replaced with
    the appropriate number, given the length of data.
    """
try:
    return struct.unpack(fmt, data)
except struct.error:
    flen = struct.calcsize(fmt.replace('*', ''))
alen = len(data)
idx = fmt.find('*')
Python: распаковать символы формата