How to read "Unsigned 8/16/24/32/64-bit integer" from binary file ? ( big-endian byte order ) unpack ? any examples ?
Asked
Active
Viewed 6,665 times
4
-
possible duplicate of [how to read info from binary file](http://stackoverflow.com/questions/6761461/how-to-read-info-from-binary-file) – S.Lott Jul 21 '11 at 12:51
-
more like http://stackoverflow.com/questions/1163459/reading-integers-from-binary-file-in-python – Caltor Oct 16 '12 at 23:39
1 Answers
4
Use the struct module. That covers 8,16,32 and 64 bits. 24 bits you will need to do some extra fiddling yourself
Examples are here

John La Rooy
- 295,403
- 53
- 369
- 502
-
Can you give an example for converting (2) 12-bit data stored in 3 in-order bytes into 2 ints? These are stored in a binary file. – nmz787 Sep 05 '14 at 04:28