Question about binary file reading

vibgyorbits bkajey at gmail.com
Wed Mar 4 17:58:38 EST 2009


I'm writing a tool to do some binary file comparisons.
I'm opening the file using

fd=open(filename,'rb')

# Need to seek to 0x80 (hex 80th) location

fd.seek(0x80)

# Need to read just 8 bytes and get the result back in hex format.
x=fd.read(8)
print x

This prints out garbage. I would like to know what am i missing here.
Basically, I am trying to read
8 bytes from location 0x80 from a binary file called "filename"

Any tips/inputs are welcome.

thanks!




More information about the Python-list mailing list