Why am I getting an AttributeError when trying to print out(转载)
来源:互联网 发布:jquery.easing.min.js 编辑:程序博客网 时间:2024/06/07 22:31
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 urllib2req = 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.reasonAttributeError: 'HTTPError' object has no attribute 'reason'
How come this is happening?
UPDATE
When I try to print out the code attribute it works fine
import urllib2req = urllib2.Request('http://www.pretend-o-server.org')try: urllib2.urlopen(req)except urllib2.URLError, e: print e.code
0 0
- Why am I getting an AttributeError when trying to print out(转载)
- Why am I getting an error converting a Foo** → Foo const**?
- [lucene异常]why am I getting a TooManyClause exception
- ORA-04030: out of process memory when trying to allocate
- I'm trying to understand the XML Spec: why doe....
- Why am I here?
- Why I am Here
- why I am here?
- Why am I getting LNK2019 unresolved external for my inline function?
- Smack “No Response From Server”. Not sure why am i getting this error
- Why am I getting this error “Expected resource of type raw” in Android Studio?
- Why why why why why am i a developer?
- Why I am so busy
- Why am i a number?
- ORA-04030: out of process memory when trying to allocate 64544 bytes (sort subheap,sort key)
- ORACLE ORA-04030之 out of process memory when trying to allocate
- ies4linux异常:An error occured when trying to cabextract some files.
- XPE:设备驱动错误an error occurred when trying to add a registry resource解决方法
- Laravel框架
- Apache Spark探秘:多进程模型还是多线程模型?
- linux常用命令export
- C++ 无锁队列 ABA <1>
- dubbo zookeeper
- Why am I getting an AttributeError when trying to print out(转载)
- Spring Boot 配置日志输出等级
- c++ 内存分配过程(通过汇编,寄存器和Memory分析)
- 在RaspberryPi中用Pygame做信息显示屏
- 日志工具Log
- 当装了dreamweaver等某些IDE时,css失效了,其中1个原因
- dfafdsa
- 使用jni计算两个数字的结果
- 关于ArrayList的5道面试题