[Solved] Convert file of bytes to ints Python [duplicate]


You might want to read Read ints from file in python
It is even more straightforward from that question.

I have not checked the following code but something along the spirit of

fin = open("hi.bmp", "rb")
out = open("values.txt","rw")
value = struct.unpack('i', fin.read(4))[0]
out.write("%d\n" % value) # just loop over the 2 last lines
out.close()
fin.close()

should do the trick, if you want to record the ints as readable integers in another file.

solved Convert file of bytes to ints Python [duplicate]