mindong 发表于 2017-4-23 07:26:52

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]{3}{3}[^A-Z]', text)
print(''.join(x for x in list))
f.close();
页: [1]
查看完整版本: python challenge 3