+ 1

How to read a binary file using python

Please reply how can I read a binary file using python and how to create it

29th Sep 2024, 3:00 AM
Ambuj Singh
Ambuj Singh - avatar
2 odpowiedzi
+ 7
You use the open command. It takes two parameters. First is the filename as a string. Second is the open mode as a string. The open mode can be "wb" to write binary or "rb" to read binary. with open("file.dat", "wb") as f: f.write(myblob)
29th Sep 2024, 3:12 AM
Jerry Hobby
Jerry Hobby - avatar
+ 4
To read a binary file, you need to open it in 'rb' mode (read binary mode). You can read the binary content using read(). Here is a sample code snippet, e.g. https://sololearn.com/compiler-playground/cjb6HPDdto3j/?ref=app
29th Sep 2024, 3:48 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar