Why am I getting an AttributeError when trying to print out(转载)
2016-05-10 18:13
459 查看
9down votefavorite 3 | I am learning about urllib2 by following this tutorial http://docs.python.org/howto/urllib2.html#urlerrorRunning the code below yields a different outcome from the tutorial import urllib2 req = urllib2.Request('http://www.pretend-o-server.org') try: urllib2.urlopen(req) except urllib2.URLError, e: print e.reason Python interpreter spits this back Traceback (most recent call last): File "urlerror.py", line 8, in <module> print e.reason AttributeError: 'HTTPError' object has no attribute 'reason' How come this is happening? When I try to print out the code attribute it works fine |
相关文章推荐
- robotium从入门到放弃 四 Robotium常用API
- address
- C++<typeinfo>之typeid
- GitLab安装说明
- 完美解决imageloader加载https图片
- iOS获取所有照片
- Laravel框架
- 我们应当怎样做需求分析
- c++第五次实验-字符串
- QT的程序开机自启动方法
- cmake简介
- Jaxb annotation初步使用
- jax-rs简介
- Postgresql外部表的使用:file_fdw
- ArrayList和LinkedList的操作性能对比
- python xmlrpc实现二进制文件传输的代码,简单的远程调用
- 与管道相关的几个命令处理
- 2dx-lua quick打包去掉蓝色启动页
- 利用pscp实现从putty远程终端复制文件到本地windows操作系统
- 欢迎使用CSDN-markdown编辑器