I believe your question is not strictly related to Python, but for any language, as the problem relates to: What is a binary file. A binary file is just 0
and 1
(many times is read directly in hexa
) for which you have to know how the structure that is saved (usually a struct
) is being serialized.
For that reason, you have to know what kind of file you're reading, and have a Parser that will know the binary structure for that specific file. That's why you have libraries. Each library knows one or multiple types of files to read/write. In Linux (for example), the extension is completely irrelevant, the content of the file is the one that's important.
To be more exact for your request, some links to help you drive through How to read/process <your-file-format> in python
(know that extension is not important, the file format is important!)