How to get the mime type of a file in Python

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

Please Share us:
Please rate this snippet

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

Leave a Reply