Discuss / Python / 也不知道能不能这么写

也不知道能不能这么写

Topic source
def bmp_info(data):
    bm = struct.unpack('<ccIIIIIIHH', bmp_data[:30])
    if bytes.decode(bm[0]+bm[1]) == 'BM':
        return {
            'width': bm[6],
            'height': bm[7],
            'color': bm[9]
        }
    else:
        return '不是位图文件'

  • 1

Reply