相关疑难解决方法(0)

在我的,而不是库代码中停止异常

我正在使用Python库开发一个应用程序,urllib由于无法访问URL,有时会出现异常情况.

但是,异常会在标准库堆栈中引发近6个级别:

/home/user/Workspace/application/main.py in call(path)
     11                                  headers={'content-type': 'application/json'},
     12                                  data=b'')
---> 13     resp = urllib.request.urlopen(req)          ####### THIS IS MY CODE
     14     return json.loads(resp.read().decode('utf-8'))

/usr/lib/python3.4/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    159     else:
    160         opener = _opener
--> 161     return opener.open(url, data, timeout)
    162 
    163 def install_opener(opener):

/usr/lib/python3.4/urllib/request.py in open(self, fullurl, data, timeout)
    461             req = meth(req)
    462 
--> 463         response = self._open(req, data)
    464 
    465         # post-process response

/usr/lib/python3.4/urllib/request.py in _open(self, req, data)
    479         protocol = …
Run Code Online (Sandbox Code Playgroud)

python exception-handling exception ipython

9
推荐指数
1
解决办法
383
查看次数

标签 统计

exception ×1

exception-handling ×1

ipython ×1

python ×1