it is necessary to check whether the address of the site 'http://ru.stackoverflow.com' exists in the href variable

 href = 'http://ru.stackoverflow.com/questions/ask' 
  • four
    Do you need a regular schedule or just check for the presence of a string in a string? then so if 'http://ru.stackoverflow.com' in your_var: ... - KoVadim
  • one
    A regular page is needed, a link to any page can be stored in a variable, and you only need to check the site if it is in this link or not. ru.stackoverflow.com - Kill Noise
  • one
    My code above should solve this problem. Even if there is a link and some text. - KoVadim
  • one
    Yes, it worked, thanks) - Kill Noise
  • 2
    You will not believe it, but it is written very simply - if "str" not in "other str": - KoVadim

1 answer 1

Form a complete answer.

Check for one line in another

 s = 'tt' st = 'testtest' if s in st: print "входит" 

check for "not included"

 s = 'tb' st = 'testtest' if s not in st: print "не входит" 

Check if the line starts with the given one.

 s = 'te' st = 'testtest' if st.startswith(s): print "начинается с"