oct_len = len(oct)
fmt_mapping = dict({(8): '>HBBBBBB', (11): '>HBBBBBBcBB'})
if oct_len == 8 or oct_len == 11:
    t = struct.unpack(fmt_mapping[oct_len], oct)
print('date tuple: %s' % repr(t))
Convert snmp octet string to human readable date format