Discuss / Python / 交作业

交作业

Topic source

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


  • 1

Reply