how to get a filename's extension

limodou limodou at gmail.com
Sun Sep 3 21:03:17 EDT 2006


On 3 Sep 2006 17:46:32 -0700, SuperGh0d at gmail.com <SuperGh0d at gmail.com> wrote:
> Hello all,
>
> I am new to python and I am having some difficulty obtaining the
> extension of a file. I was looking at the re.match module but I am
> completely overwhelmed by regular expressions. Is there an easier way
> to get the extension for a file name like:
>
> this.is.my.file.avi
>
> I would just like to pull out the 'avi'
>
> your help is greatly appreciated! :)
>
>>> import os
>>> os.path.splitext('this.is.my.file.avi')
('this.is.my.file', '.avi')

-- 
I like python!
My Blog: http://www.donews.net/limodou
UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad
UliPad Maillist: http://groups.google.com/group/ulipad



More information about the Python-list mailing list