python check pattern in string [duplicate]
Possible Duplicate:
Python - Check If Word Is In A String.
i have a string 开发者_如何学Pythonwhich 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?
Are you looking for this?
if "/somefolder/" in my_url:
#whatever
Use:
print 'somefolder' in my_url
OR
print my_url.index('somefolder')
精彩评论