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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.