我是 python 新手,我正在尝试使用一个库。它引发了一个异常,我正在尝试确定哪个异常。这就是我正在尝试的:
except tweepy.TweepError as e:
print e
print type(e)
print e.__dict__
print e.reason
print type(e.reason)
这就是我得到的:
[{u'message': u'Sorry, that page does not exist', u'code': 34}]
<class 'tweepy.error.TweepError'>
{'reason': u"[{u'message': u'Sorry, that page does not exist', u'code': 34}]", 'response': <httplib.HTTPResponse instance at 0x00000000029CEAC8>}
[{u'message': u'Sorry, that page does not exist', u'code': 34}]
<type 'unicode'>
我试图得到那个代码。我试过 e.reason.code 没有成功,我不知道该尝试什么。