To get the mime type of a file in Python you can use the following snippet.

Sample Python

import mimetypes

fileType,fileEncoding = mimetypes.guess_type('/path/file.exe')
print fileType,fileEncoding

One thought on “How to get the mime type of a file in Python”

Leave a Reply