使用python 3.x 对pythonchallenge-----3的解答过程
2017-09-01 15:05 太烦人 阅读(308) 评论(0) 收藏 举报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("\n","")
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
心得:我在这里使用正则标示进行全文匹配去解决的

浙公网安备 33010602011771号