reading in ints from binary files
Bill
metaliu at yahoo.com
Mon Mar 25 13:58:53 EST 2002
Quick Newb question:
How do I read in integers from binary files? readlines() reads returns the
data in as a string. I can manipulate the string to get the desired result.
However, is there an easier way of doing this? I currently do something
like:
f=open('file', 'rb')
s = f.readline()
l = list(s[0:-1])
l.reverse()
a = array.array('h', ''.join(l))
There's gotta be an easier way.
Thanks in advance,
Bill
More information about the Python-list
mailing list