Python 数据结构报错如何解决?
self.auth = HTTPProxyAuth(“XXX”, “XXXX”)
self.proxies = {“http”: “XXXX:XXX”}
self.auth_1=HTTPProxyAuth(“asdas”, “te814”)
self.proxies_1 = {“http”: “123.249.90.19:888”}
self.auth_list={0:{self.auth:self.proxies_1},1:{self.auth_1:self.proxies_1}}
我这样写报错
File “/home/shenjianlin/my_project/qimingpian_person/qimingpian_person.py”, line 37, in init
self.auth_list={0:{self.auth:self.proxies_1},1:{self.auth_1:self.proxies_1}}
TypeError: unhashable type: 'HTTPProxyAuth’
Python 数据结构报错如何解决?
1 回复
HTTPProxyAuth 这个类能够 hash 吗? Python 字典的 key 只支持能够 hash 的量,比如你用 list 作 key 就会报 unhashable type 的错误

