[Tutor] How to read all integers from a binary file?
David Aldrich
David.Aldrich at EMEA.NEC.COM
Fri Oct 9 17:02:20 CEST 2015
Hi
I have a binary file of 32-bit unsigned integers. I want to read all those integers into a list.
I have:
ulData = []
with open(ulBinFileName, "rb") as inf:
ulData.append(struct.unpack('i', inf.read(4)))
This obviously reads only one integer from the file. How would I modify this code to read all integers from the file please?
Best regards
David
More information about the Tutor
mailing list