玩蛇网提供最新Python编程技术信息以及Python资源下载!

python报错信息type 'exceptions.AttributeError'是什么意思

python
报错

Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
  File "/usr/lib/python2.6/threading.py", line 484, in run
  File "dxcad.py", line 243, in threadget
  File "dxcad.py", line 181, in gethtml
  File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
  File "/usr/lib/python2.6/urllib2.py", line 391, in open
  File "/usr/lib/python2.6/urllib2.py", line 409, in _open
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
  File "/usr/lib/python2.6/urllib2.py", line 1190, in http_open
  File "/usr/lib/python2.6/urllib2.py", line 1164, in do_open
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'

代码

def gethtml(url):
    encoding_support = ContentEncodingProcessor
    prodom=proxylist[random.randint(0,proxn)]
    proxy_support = urllib2.ProxyHandler({'http':prodom})
    opener = urllib2.build_opener(proxy_support,encoding_support,urllib2.HTTPHandler)
    urllib2.install_opener(opener)
    try:
        bpanhtml = urllib2.urlopen(url,timeout = 2).read()
    except Exception,e:
        print e
        return gethtml(url)
    return bpanhtml

求教

不要在线程中 install_opener

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd19130.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月14日 - 11时44分57秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules