Discuss / Python / 练习

练习

Topic source

米粽粽

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

def check_bmp(filename):
    f = open(filename, 'rb')
    h = f.read(30)
    s = struct.unpack('<ccIIIIIIHH', h)

    if s[0] == b'B' and s[1] == b'M' or s[1] == b'A':
        print(str(s[6]) + 'x' + str(s[7]) + '@' + str(s[9]))

  • 1

Reply