Discuss / Python / Check函数

Check函数

Topic source

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()


  • 1

Reply