'htmla subtle thingthe second item in the tuple returned from the mimetypes guess is an encoding type we won' use here for opening purposes we still have to pay attention to itthough--if it is not noneit means the file is compressed (gzip or compress)even if we receive media content type for exampleif the filename is something like spam gif gzit' compressed image that we don' want to try to open directlymimetypes guess_type('spam gz'(none'gzip'content unknown mimetypes guess_type('spam gif gz'('image/gif''gzip'don' play memimetypes guess_type('spam zip'('application/zip'nonearchives mimetypes guess_type('spam doc'('application/msword'noneoffice app files if the filename you pass in contains directory paththe path portion is ignored (only the extension is usedthis module is even smart enough to give us filename extension for type--useful if we need to go the other wayand create file name from content typemimetypes guess_type( ' :\songs\sousa au'('audio/basic'nonemimetypes guess_extension('audio/basic'autry more calls on your own for more details we'll use the mimetypes module again in ftp examples in to determine transfer type (text or binary)and in our email examples in and to sendsaveand open mail attachments in example - we use mimetypes to select table of platform-specific player commands for the media type of the file to be played that iswe pick player table for the file' media typeand then pick command from the player table for the platform at both stepswe give up and run web browser if there is nothing more specific to be done using mimetypes guesses for searchvisitor to use this module for directing our text file search scripts we wrote earlier in this simply extract the first item in the content-type returned for file' name for instanceall in the following list are considered text (except pyw"which we may have to special-case if we must care)for ext in [txt'py'pyw'html' ' 'xml']print(extmimetypes guess_type('spamext)playing media files