Python探路者 2018-10-15
如下所示:
def getWordPattern(word): pattern = [] usedLetter={} count=0 for i in word: if i not in usedLetter: usedLetter[i]=count count+=1 pattern.append(str(usedLetter[i])) return '.'.join(pattern) def main(): print getWordPattern("hello") if __name__=="__main__": main()