Hi,
I want to know how to read the binary file from 10th byte to 90th byte in a file size of 100 bytes and need to write the read data into new binary file.
please help me in doing this.

with open('binfile.dat', 'rb') as bf:
      bf.seek(10)
      open('out.dat', 'wb').write(bf.read(80))

Something like this. This is untested as I am not with computer now. Maybe you must seek(9) and/or read(81).

You should be able to read the 100 bytes, split and write. The following code uses 25 bytes and splits from 10 through 20 (11 bytes) for simplicity.

alpha = "abcdefghijklmnopqrstuvwxy"
print alpha
print alpha[9:20]

The first solution really worked for me.. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.