python - 为什么我不能通过 pygtrie 在 trie 中添加单词?

标签 python algorithm python-2.7 data-structures trie

我想构建一个 trie 来记录短语。因此单位是单词而不是字符。我通过谷歌找到了一个很有前途的实现 here .但是根据他们的documentation , 没有 add 功能。我想知道如何在 trie 中添加/插入单词?提前致谢!

最佳答案

此 trie 实现提供与 dict 相同的接口(interface)。您的 add 函数将只是 mytrie[key] = value

关于python - 为什么我不能通过 pygtrie 在 trie 中添加单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42875886/

相关文章:

javascript - 使用 Javascript 将页面打印为 PDF(使用 Django)

algorithm - PCMU淡出效果

algorithm - Heapsort可以应用于最小堆数据结构吗?

python - 在 Python 中使用 IFF

python - Autotools - 当 Python 3 可用时使用 Python 2.7

Python - 将 GPS 位置批量转换为 Lat Lon 小数

python - 如何使用 tkinter 制作计时器?

python - 值错误 : could not convert string to float: '−4.0'

算法帮助,数学很烂

python - 是否有可能在 python 中杀死正在监听特定端口的进程,例如 8080?