【python】TypeError: unhashable type: ‘list‘ 解决方法——简单示例
类型错误,list是不可哈希的例1:向set()中添加list,需要转为tuple才能加进去res=set()tmp=[-1,-1,2]res.add(tuple(tmp))print(res)#{(-1,-1,2)}例2:利用set()去重res=[[-1,-1,2],[-1,0,1],[-1,0,1]]set_res=set(tuple(item)foriteminres)print(set_