Home > other >  Please write write binary format error is why?
Please write write binary format error is why?

Time:12-05

The test code:
Tf=open (T.b 'in' and 'wb)
Tf. Write (struct. Pack (' & lt; HHHH ', width, hight, format_ pixel_size))
Tf. The close ()

Code is so simple, struct. Pack (' & lt; HHHH ', 134, 38, 1, 4) print is no problem, format is b '\ x86 \ x00 \ x26 \ x00 \ x01 \ x00 \ x04 \ x00'
But the bin file data only c2 86 26 01 04
Rather than the expected 86 00 00 26 01 00 00 04
Excuse me what reason be?

CodePudding user response:

Use other editors to see, right, direct reading seems to be no problem,

  • Related