python——3.x的异常处理 请注意了

以前的python2.x的时候:
try:
        fp=urllib.request.urlopen(blogurl)
    except Exception, e:
        print (e)
        print('download exception %s' % blogurl)
        return 0
 
现在python3.x的时候:
try:
        fp=urllib.request.urlopen(blogurl)
    except Exception as e:
        print (e)
        print('download exception %s' % blogurl)
        return 0
否则会报错的
 
 
 

 

posted @ 2014-11-02 09:57  落叶落叶  阅读(224)  评论(0编辑  收藏  举报