[Tutor] url parsing

Jay Jesus Amorin jay.amorin at gmail.com
Sun Feb 15 14:33:26 CET 2009


Thanks this is much more simple and is what i need.

On Sun, Feb 15, 2009 at 9:29 PM, Lie Ryan <lie.1296 at gmail.com> wrote:

> On Sun, 15 Feb 2009 14:22:09 +0100, Andre Engels wrote:
> > What is 'new' in your solution? Apart from that, the following looks
> > simpler:
> >
> >>>> url = "http://this/is/my/url/to/parse" parts = url.split('/')
> >>>> sol = '/'.join(parts[:-1])
> >>>> sol
> > 'http://this/is/my/url/to'
>
> do you want something even more simpler?
>
> >>> url ="http://this/is/my/url/to/parse"
> >>> url.rsplit('/', 1)[0]
> 'http://this/is/my/url/to'
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090215/9b4fac38/attachment-0001.htm>


More information about the Tutor mailing list