mimetypes.MimeTypes

class mimetypes.MimeTypes(filenames=(), strict=True)[source]

MIME-types datastore.

This datastore can handle information from mime.types-style files and supports basic determination of MIME type from a filename or URL, and can guess a reasonable extension given a MIME type.

Methods

__init__([filenames, strict])
add_type(type, ext[, strict]) Add a mapping between a type and an extension.
guess_all_extensions(type[, strict]) Guess the extensions for a file based on its MIME type.
guess_extension(type[, strict]) Guess the extension for a file based on its MIME type.
guess_type(url[, strict]) Guess the type of a file based on its URL.
read(filename[, strict]) Read a single mime.types-format file, specified by pathname.
read_windows_registry([strict]) Load the MIME types database from Windows registry.
readfp(fp[, strict]) Read a single mime.types-format file.