how to get a filename's extension

Discussion in 'Python' started by SuperGh0d@gmail.com, Sep 4, 2006.

  1. Guest

    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! :)
    , Sep 4, 2006
    #1
    1. Advertising

  2. limodou Guest

    On 3 Sep 2006 17:46:32 -0700, <> 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
    limodou, Sep 4, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,002
    Travis Murray
    Aug 24, 2004
  2. Replies:
    1
    Views:
    1,428
    Roland de Ruiter
    Jun 15, 2006
  3. Lad
    Replies:
    8
    Views:
    427
    Tom Anderson
    Dec 9, 2005
  4. Ed
    Replies:
    10
    Views:
    45,719
    alok000707
    Jul 13, 2010
  5. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    731
    Jonathan N. Little
    May 30, 2008
Loading...

Share This Page