<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_fmt(fmt, fp):
 """ Reads data from ``fp`` according to ``fmt``. """

    fmt = str(">" + fmt)
    fmt_size = struct.calcsize(fmt)
    data = fp.read(fmt_size)
    assert len(data) == fmt_size, 'read=%d, expected=%d' % (
        len(data), fmt_size
    )
    return struct.unpack(fmt, data)