推荐学习书目
› 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 · Aug 15, 2018 · 1905 views
    This topic created in 2973 days ago, the information mentioned may be changed or developed.
    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  
       Aug 15, 2018
    HTTPProxyAuth 这个类能够 hash 吗? Python 字典的 key 只支持能够 hash 的量,比如你用 list 作 key 就会报 unhashable type 的错误
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1376 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 16:20 · PVG 00:20 · LAX 09:20 · JFK 12:20
    ♥ Do have faith in what you're doing.