您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

用Python散列数组

用Python散列数组

就试一试吧:

>>> hash((1,2,3))
2528502973977326415
>>> hash([1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> hash(frozenset((1,2,3)))
-7699079583225461316
>>> hash(set((1,2,3)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'set'

所以,你可以得到hashtuple,并frozenset因为是不可变的,你不能做到这一点list,并set因为他们是可变的。

python 2022/1/1 18:34:42 有303人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶