Discuss / Python / 交作业

交作业

Topic source
import  struct
def  check(path):
  with open(path,"rb") as f :
      info = struct.unpack('<ccIIIIIIHH', f.read(30))
      if info[0]==b"B"and info[1]==b"M":
        print("是BMP图像")
        print(info)
        print("宽",info[-4], "高", info[-3])
        print("颜色数",info[-1])
      else:
        print("不是BMP图像")

  • 1

Reply