Here I'm trying to read a .bin file in PyCharm, I made a for in loop with range to make the reading limited because the file is so big (around 8GB)
read = open("D:\Office\Hadith Library\data\shamela.bin", 'rb')
for i in range(0,10):
p = read.read(8)
print(p , "\n")
The outcome I get from the print statement is:
b'PK\x03\x04\n\x00\x00\x00'
b'\x00\x00\x9bt\x8bQ\x00\x00'
b'\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\x00\t\x00\x00\x0014'
b'42.041/P'
b'K\x03\x04\n\x00\t\x00\x00'
b'\x00\xa4l\x8bQ\x00\x00\x00'
b'\x00\x0c\x00\x00\x00\x00\x00\x00'
b'\x00\x1a\x00\x00\x00144'
b'2.041/14'
Why's that? What's going on? appreciate the help!
.bin
files are usually "binary" files as suggested in its name, and this behaviour is expected - it's printing out binary.
If you know the format of the .bin file, you can try and decode it with struct
- check the docs here . If you don't - then you typically won't be able to retrieve useful information from it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.