python查找并删除驼峰字符串

 驼峰字符串特点:AFA,AEA,aca,afa,长度为奇数

def tuofeng(a_str):
    if len(a_str) < 3: return a_str
    res = []
    for item in a_str:
        if len(res)>2:
            if res[-1] == res[-3]:
                del res[-3:]
                print res
        res.append(item)
        print(res)
    print( "".join(res))

if __name__ == '__main__':
    a='aaAFAesfadcecda'
    tuofeng(a)

你可能感兴趣的:(Python,算法,python,算法,开发语言)