python得到单词模式的示例
如下所示: 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() 以上这篇python得到单词模式的
用户评论