def unpack(fmt, astr):
    """
    Return struct.unpack(fmt, astr) with the optional single * in fmt replaced with
    the appropriate number, given the length of astr.
    """
try:
    return struct.unpack(fmt, astr)
except struct.error:
    pass
Неопределенная длина байта в Python