开发者

python read binary from specific position

开发者 https://www.devze.com 2023-04-12 03:56 出处:网络
I have a huge binary file from which I want to read some byt开发者_运维百科es from exact positions in the file. How can I access specific bytes from binary file not having to loop through all bytes fr

I have a huge binary file from which I want to read some byt开发者_运维百科es from exact positions in the file. How can I access specific bytes from binary file not having to loop through all bytes from the beginning of the file? Thanx,


Make sure you open the file with the "b" attribute (for example: file("myfile.bin", "rb")). Then use the seek() method of the file object.

Look here: http://docs.python.org/release/2.4.4/lib/bltin-file-objects.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号