工程实践_Python中字典初始化时出现TypeError: unhashable type: ‘list‘错误的原因

题目中的答案应该选D。

Python中字典初始化时如果里面含有列表则会出现TypeError: unhashable type: 'list’的错误。

原因是列表是可变的type,而字典中的哈希类型必须是不可变得type,比如元组。

所以可以将数组改成元组就没有问题了。

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-07-07
  • 2021-04-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-04-29
  • 2021-07-12
  • 2022-12-23
相关资源
相似解决方案