import struct, os
def bmp_check(path): f = open(path, 'rb') s = f.read(30) s = struct.unpack('<ccIIIIIIHH', s)
if s[0] == b'B' and s[1] == b'M': print('是位图,大小为 %s * %s, 颜色数为 %s'% (s[6],s[7],s[-1])) else: print('不是位图')
少写一句 f.close()
Sign in to make a reply
_Indescribable
import struct, os
def bmp_check(path): f = open(path, 'rb') s = f.read(30) s = struct.unpack('<ccIIIIIIHH', s)