首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

unhashable type:'list'什么意思,该怎么处理

2012-05-20 
unhashable type:list什么意思unhashable type:list什么意思Python中[解决办法]Lists cannot be dicti

unhashable type:'list'什么意思
unhashable type:'list'什么意思 
Python中

[解决办法]
Lists cannot be dictionary keys – more on this later:
>>> mydict = {[1,2] : "wont_work"}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

list的内容是可变的,不可hash,因此不能作为dict的keys.

热点排行