Discuss / Python / 作业

作业

Topic source
def bmp_info(data):
    if struct.unpack('<cc', data[:2]) == (b'B', b'M'):
        return {
            'width': struct.unpack('<I', data[18:22])[0],
            'height': struct.unpack('<I', data[22:26])[0],
            'color': struct.unpack('<H', data[28:30])[0]
        }
    return print('not BMP')

  • 1

Reply