#!/usr/bin/python
import string
fp = open('./3.dat','r')
str = fp.read()
for i in range(len(str)):
flag = True
if not str[i].islower():
continue
for j in range(3):
if not str[i+j+1].isupper():
flag = False;
break;
if not flag:
continue
if not str[i+4].islower():
continue
for j in range(3):
if not str[i+5+j].isupper():
flag = False;
break
if not flag:
continue
if not str[i+8].islower():
continue
print str[i+4],
|
这个办法我自己都觉得笨得不行,还是贴一个简洁的给大家看看
>>> import re
>>> "".join(re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]', text))
'linkedlist'
阅读(791) | 评论(0) | 转发(0) |