On this page
  1. mimetypes.guess_type
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

mimetypes.guess_type

Prev: mimetypes.guess_file_type | Up: mimetypes | Next: mimetypes.init
Rel: mimetypes.add_type, mimetypes.guess_all_extensions, mimetypes.guess_extension, mimetypes.guess_file_type
Ref: docs.python.org — mimetypes.guess_type
Tags: #public #python3 #stdlib #mimetypes


Import

import mimetypes
from mimetypes import guess_type

Signature & Overview

mimetypes.guess_type(url, strict=True)

Guess the type of a file based on its URL.

Usage

import mimetypes

ctype, enc = mimetypes.guess_type("archive.tar.gz")
assert ctype == "application/x-tar" and enc == "gzip"

Gotchas

REPL Inspect

from mimetypes import guess_type
help(guess_type)

Linked from

Related notes