How to find the mime type of a file in python?

前端 未结 19 1160
猫巷女王i
猫巷女王i 2020-11-22 15:19

Let\'s say you want to save a bunch of files somewhere, for instance in BLOBs. Let\'s say you want to dish these files out via a web page and have the client automatically o

19条回答
  •  迷失自我
    2020-11-22 15:39

    There are 3 different libraries that wraps libmagic.

    2 of them are available on pypi (so pip install will work):

    • filemagic
    • python-magic

    And another, similar to python-magic is available directly in the latest libmagic sources, and it is the one you probably have in your linux distribution.

    In Debian the package python-magic is about this one and it is used as toivotuo said and it is not obsoleted as Simon Zimmermann said (IMHO).

    It seems to me another take (by the original author of libmagic).

    Too bad is not available directly on pypi.

提交回复
热议问题