[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: get a field

Steve Holden

2/15/2010 4:54:00 PM

mierdatutis mi wrote:
> Hi,
>
> I have this:
>
> pe="http://www.rtve.es/mediateca/videos/20100211/saber-comer---patatas-castellanas-costillas-11-02-10/691046.s...
>
>
> I would like to extract this: 691046.shtml
>
> But is dynamically. Not always have the same lenght the string.
>
> Could you help me how could I do extract this in python?
>
> Many thanks and sorry for my English!
>

>>> s = "http://server/path/to/file/file.shtml"
>>> s.rfind("/") # finds rightmost "/"
26
>>> s[s.rfind("/")+1:] # substring starting after "/"
'file.shtml'
>>>

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us....
Holden Web LLC http://www.hold...
UPCOMING EVENTS: http://holdenweb.event...