Networking and Internet Modules
mimetypes
Maps filenames and extensions to media types and content encodings. This is a naming-based guess, not inspection of actual bytes or a security validation. MimeTypes supports local mappings; system tables may differ. guess_file_type is available in Python 3.13.
Formal Syntax & Structure
python syntaxpython
import mimetypesReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from mimetypes import MimeTypestypes = MimeTypes(filenames=())print(types.guess_type("report.txt")[0])