On 31May2019 12:38, ingo <i...@ingoogni.nl> wrote:
Many file formats have "magic bytes" that you can use for that purpose.
https://en.wikipedia.org/wiki/List_of_file_signatures

Also, UNIX systems ship with a command called "file" which inspects a file's leading data for such magic numbers to identify their content. And there's a library called libmagic [1,2] which does this work, and there's a PyPI package called python-magic [3] for using this from Python, not to mention various other PyPI modules [4].

1: https://sourceforge.net/projects/libmagic/
2: https://github.com/threatstack/libmagic
3: https://pypi.org/project/python-magic/
4: https://pypi.org/search/?q=magic

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to