[Tutor] url parsing
Lie Ryan
lie.1296 at gmail.com
Sun Feb 15 14:29:37 CET 2009
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'
More information about the Tutor
mailing list