Mime function in Python
Joonas Paalasmaa
joonas at olen.to
Wed Oct 3 08:18:21 EDT 2001
Mark Berry wrote:
>
> Anyone know of an easy way to determine the mime type of a file?
>
> For example... (my dream method)
>
> type = dream.get_mime('/tmp/myfile.jpg')
> print type
> ['image/jpeg']
>
> basically something to that effect.. Is there anything in the core
> libs that would do something like that or am I going to have to hack
> something out?
import mimetypes
type = mimetypes.guess_type('/tmp/myfile.jpg')
print type
More information about the Python-list
mailing list