清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
class Zipper: def zipString(self, iniString): nlen = len(iniString) rest =[] i = 0 endflag = 0 while i < (nlen-1): for j in range(i+1, nlen): if iniString[i] == iniString[j]: continue else: rest.append((iniString[i], i, j)) endflag = j break i = j rest.append((iniString[endflag], endflag, nlen)) resStr = "" for item in rest: resStr += (item[0] + str(item[2]-item[1])) if len(resStr) >= nlen: return iniString else: return resStr a = Zipper() print a.zipString('aabcccccaaa') b = Zipper() print b.zipString('welcometonowcoderrrrr') c = Zipper() bstr= c.zipString('qwertyuioplkjhgfdsAzxcvbNM') print type(bstr)