0

Possible Duplicate:
Python - Check If Word Is In A String.

i have a string which is a url e.g.

my_url = "http://mysite.com/somefolder/somefile"

I want check if "somefolder" is in the my_url file

how do I do that?

Community
  • 1
  • 1
John
  • 19,837
  • 40
  • 111
  • 151

2 Answers2

5

Are you looking for this?

if "/somefolder/" in my_url:
    #whatever
Sven Marnach
  • 530,615
  • 113
  • 910
  • 808
0

Use:

print 'somefolder' in my_url

OR

print my_url.index('somefolder')
Artsiom Rudzenka
  • 26,491
  • 4
  • 32
  • 51