Discuss / Python / 作业

作业

Topic source

LesLieM樂

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

with open('C:/users/xyeg/desktop/z.txt', 'rb') as f:
    s = f.read()[:30]

l = struct.unpack('<ccIIIIIIHH', s)

if struct.unpack('<cc', s[:2]) == (b'B', b'M'):
    print(l[2])
    print(l[9])
else:
    print('Not a Windows BMP!')

  • 1

Reply