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
  • 21,047
  • 43
  • 114
  • 155

2 Answers2

5

Are you looking for this?

if "/somefolder/" in my_url:
    #whatever
Sven Marnach
  • 574,206
  • 118
  • 941
  • 841
0

Use:

print 'somefolder' in my_url

OR

print my_url.index('somefolder')
Artsiom Rudzenka
  • 27,895
  • 4
  • 34
  • 52