Python if语句无法按预期工作

-1 python

我正在网站中搜索一个字符串,并检查该字符串的位置是否在预期的位置.我知道字符串从第182个字符开始,如果我打印temp,它甚至会告诉我它是182,但if语句说182不是182.

一些代码

f = urllib.urlopen(link)

 #store page contents in 's'
 s = f.read()
 f.close()
 temp = s.find('lettersandnumbers')

 if (htmlsize == "197"):
  #if ((s.find('lettersandnumbers')) == "182"):
  if (temp=="182"):
   print "Glorious"
   doStuff()
  else:
   print "HTML not correct.  Aborting."
 else:
  print htmlsize
  print "File size is incorrect.  Aborting."
Run Code Online (Sandbox Code Playgroud)

Sil*_*ost 5

str.find返回整数,而不是字符串.字符串整数比较总是返回False.