On Nov 30, 9:10 am, lookon <[EMAIL PROTECTED]> wrote:
> I have a url of image, and I want to get the filename and extension of
> the image. How to write in python?
>
> for example, the url ishttp://a.b.com/aaa.jpg?version=1.1
>
> how can I get aaa and jpg by python?

Something like...

>>> from urlparse import urlsplit
>>> from os.path import splitext
>>> splitext(urlsplit('http://a.b.com/aaa.jpg?version=1.1').path[1:])
('aaa', '.jpg')

...and then it should be fairly flexible instead of having to change
splitting etc..

hth

Jon.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to