mimetypes

The mimetypes module is used to guess the MIME type associated with a file, based on its filename extension. It also converts MIME types to their standard filename extensions. MIME types consist of a type/subtype pair. The following list shows the MIME types recognized by Python 2.4:

File SuffixMIME Type
.aapplication/octet-stream
.aiapplication/postscript
.aifaudio/x-aiff
.aifcaudio/x-aiff
.aiffaudio/x-aiff
.auaudio/basic
.avivideo/x-msvideo
.battext/plain
.bcpioapplication/x-bcpio
.binapplication/octet-stream
.bmpimage/x-ms-bmp
.ctext/plain
.cdfapplication/x-netcdf
.cpioapplication/x-cpio
.cshapplication/x-csh
.csstext/css
.dllapplication/octet-stream
.docapplication/msword
.dotapplication/msword
.dviapplication/x-dvi
.emlmessage/rfc822
.epsapplication/postscript ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.