Discuss / Python / 作业

作业

Topic source

Super-String

#1 Created at ... [Delete] [Delete and Lock User]
def bmp_info(data):
    # 解析位图文件头部信息
    info = struct.unpack('<ccIIIIIIHH', data[:30])
    if info[0] != b'B' or info[1] != b'M':
        raise ValueError('Not a BMP file')
    return {
        'width': info[6],
        'height': info[7],
        'color': info[9]
    }


  • 1

Reply