原题地址:http://www.pythonchallenge.com/pc/def/equality.html
已给提示:One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.(一个小写字母,被三个大写字母左右包围)
根据经验,给出大字符串在网页源代码注释中!!
一看应该是字符串处理,找被三个大写字母左右包围的小写字母。那就用最方便的正则表达式处理。
import urllib2
import re
f=urllib2.urlopen('http://www.pythonchallenge.com/pc/def/equality.html')
data=f.read()
#reg=re.compile('[a-z]{1}[A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]{1}')
reg=re.compile('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]')
print ''.join(reg.findall(data))
结果就是:linkedlist
所以下一关:http://www.pythonchallenge.com/pc/def/linkedlist.php