[Tutor] [tutor] how to get the fileextention?
emilia12 at mail.bg
emilia12 at mail.bg
Thu Jul 20 13:49:43 CEST 2006
Hi Ziyad
thank you very much!
E.
Цитат на писмо от ???? ?? ????????? ???????
<zamb at saudi.net.sa>:
> On Thu, 2006-07-20 at 11:19 +0300, emilia12 at mail.bg
> wrote:
> > Hi,
> >
> > is this the right (shortest) way to get the file
> extention
> > (under MS WIN)?
> >
> >
> > def getext(fname):
> > ext = fname.split('.').pop()
> > return ext
> >
> > Regards,
> > Emily
> >
> The following maybe a little better:
> def getExt(fname):
> return fname.rsplit('.', 1)[1]
>
> It uses one method instead of two compared to yours. And
> in your code
> there's no need for the ‘ext’ variable, you could use:
> def getext(fname):
> return fname.split('.').pop()
>
> For more information about ‘str’ objects type the
> following inside the
> Python shell:
> >>> help(str)
>
>
> Ziyad.
>
>
>
-----------------------------
Спортни залагания!
bg.sportingbet.com
More information about the Tutor
mailing list