get a field

Steve Holden steve at holdenweb.com
Mon Feb 15 11:54:22 EST 2010


mierdatutis mi wrote:
> Hi,
> 
> I have this:
> 
> pe="http://www.rtve.es/mediateca/videos/20100211/saber-comer---patatas-castellanas-costillas-11-02-10/691046.shtml"
> 
> 
> 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.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list