Python 数据结构报错

2018-08-15 16:35:26 +08:00
 bestehen
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'
1017 次点击
所在节点    Python
1 条回复
Pagliacii
2018-08-15 17:47:41 +08:00
HTTPProxyAuth 这个类能够 hash 吗? Python 字典的 key 只支持能够 hash 的量,比如你用 list 作 key 就会报 unhashable type 的错误

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/480087

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX