Discuss / Python / 我的作业

我的作业

Topic source

lubang03

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

import struct

def checkBmpFile(filePath): with open(filePath, 'rb') as f: s = f.read(30) info = struct.unpack('<ccIIIIIIHH', s) print(info) if(info[0] == b'B' and info[1] == b'M'): print('This image file is a bmp file with width %d, height %d and colors %d' %(info[6], info[7],info[9])) return True return False

if name == 'main': checkBmpFile('C:\Program Files\Microsoft Office\CLIPART\PUB60COR\J0101856.BMP')


  • 1

Reply