python3.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
否则会报错的

猜你喜欢

转载自blog.csdn.net/awj3584/article/details/38233293