Discuss / Python / 414解压可迭代对象赋值给多个变量

414解压可迭代对象赋值给多个变量

Topic source

31nm

#1 Created at ... [Delete] [Delete and Lock User]
import struct

def is_bitmap(file):
    with open(file, 'rb') as s:
        *type_of_file, size, _, _, _, width, height, _, color = struct.unpack('<ccIIIIIIHH', s.read(30))
        if type_of_file == [b'B', b'M']:
            print('The size of the picture is {}, and of color {}.'.format(size, color))
        else:
            print('This is not a bitmap')

  • 1

Reply