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

TypeError:不可散列的类型:'dict',当dict用作另一个dict的键时

TypeError:不可散列的类型:'dict',当dict用作另一个dict的键时

错误中,我推断这referenceElement一个字典(请参阅下面的repro)。字典不能被散列,因此不能用作另一个字典的键(或本身就是这个键!)。

>>> d1, d2 = {}, {}
>>> d1[d2] = 1
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: unhashable type: 'dict'

您可能意思是for element in referenceElement.keys()for element in json['referenceElement'].keys()。如果这两种解决方案都不起作用,那么在有关什么类型jsonreferenceElement是什么以及它们包含什么的更多上下文中,我们将能够为您提供更好的帮助。

其他 2022/1/1 18:37:38 有588人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

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

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

请先登录

推荐问题


联系我
置顶