V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

Python 数据结构报错

  •  
  •   bestehen · 2018-08-15 16:35:26 +08:00 · 1013 次点击
    这是一个创建于 2071 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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'
    Pagliacii
        1
    Pagliacii  
       2018-08-15 17:47:41 +08:00
    HTTPProxyAuth 这个类能够 hash 吗? Python 字典的 key 只支持能够 hash 的量,比如你用 list 作 key 就会报 unhashable type 的错误
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   957 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:01 · PVG 05:01 · LAX 14:01 · JFK 17:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.