【发布时间】:2015-05-20 05:12:51
【问题描述】:
我是 python 的新手,需要一些帮助。我计划使用某种 hashMap 类型的数据结构来将字符串映射到它的长度。我如何在python中做到这一点?
【问题讨论】:
-
docs.python.org/2/tutorial/datastructures.html#dictionaries。不过,这里没有什么意义,因为
len(s)是O(1)- 请参阅stackoverflow.com/q/1115313/3001761 -
重要的问题是问你为什么要这样做,你可能会在这里遇到一个经典的 XY 问题...meta.stackexchange.com/questions/66377/what-is-the-xy-problem