Discuss / Python / 作业

作业

Topic source

题目里要求判断是否位图,没说要判断是什么操作系统,所以只用了info[0]:

def bmp_info(data):

    info = struct.unpack('<ccIIIIIIHH', data[:30])

    if info[0] == b'B':

        return {

            'width': info[6],

            'height': info[7],

            'color': info[9]

        }

    return None


  • 1

Reply