python得到单词模式的示例
时间:2021-01-21 10:54:57|栏目: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实现的人工神经网络算法示例【基于反向传播算法】
栏 目:Python代码
下一篇:Pytorch损失函数nn.NLLLoss2d()用法说明
本文标题:python得到单词模式的示例
本文地址:http://www.codeinn.net/misctech/48832.html






