def Check(path): f=open(path, 'rb') d1=f.read(2) if d1==b'BM' or d1==b'BA': print('是位图') else: print('不是位图') return d2=f.read(28) t = struct.unpack('<IIIIIIHH', d2) print('图片大小:', t[0], '颜色数:', t[-1]) f.close()
Sign in to make a reply
厦大游园惊梦
def Check(path): f=open(path, 'rb') d1=f.read(2) if d1==b'BM' or d1==b'BA': print('是位图') else: print('不是位图') return d2=f.read(28) t = struct.unpack('<IIIIIIHH', d2) print('图片大小:', t[0], '颜色数:', t[-1]) f.close()