python challenge 3
第三题比较简单,One small letter, surrounded by EXACTLY three big bodyguards on each of its sides. 即一个小写字母,两边各有不多不少的三个大写字母。 用正则表达式搞定。
import re
if __name__ == '__main__':
# put the mess from the page source into 3.txt
f = open('3.txt', 'r')
text = f.read()
list = re.findall('[^a-z][a-z]{3}[a-z][a-z]{3}[^a-z]', text)
print(''.join(x[4:5] for x in list))
f.close();
正则得到列表后的处理很狡猾,我当时是老老实实再正则了一次