pythonchallenge-3地址 : http://www.pythonchallenge.com/pc/def/equality.html
图片如下:
题目解析:我已经放弃自己猜题目意思了,直接搜索攻略
一个小写字母,每边刚好有三个大写字母做保镖。例如:XXXxXXX(小写字母两边必须要有三个大写字母,超出三个大写字母也是不行的)
解题过程:
import re file_obj = open(r'./other/chakkenge3.text') try: straa = file_obj.read().replace(" ","") finally: file_obj.close() pattern = re.compile('([^A-Z])([A-Z]{3})([a-z])([A-Z]{3})([^A-Z])') list = re.findall(pattern,straa) strcc = "" for i in list: strcc =strcc + i[2] print(strcc)
答案:linkedlist
心得:我在这里使用正则标示进行全文匹配去解决的