Python'a yeni yaşıyorum ve bir kütüphane kullanmaya çalışıyorum. Bir istisna ortaya çıkarır ve hangisini tanımlamaya çalışıyorum.Hata kodunu alın tweepy istisna örneği
except tweepy.TweepError as e:
print e
print type(e)
print e.__dict__
print e.reason
print type(e.reason)
Bu alıyorum budur:
[{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'>
Im o koda almaya çalışırken bu deniyorum budur. E.reason.code'u hiç başarı ile denedim ve denemem için hiçbir fikrim yok.
Evet - Bunu yanlış yorumlayabilirdim - e.reason [0] ['code'] 'nedir? –
traceback (son En son çağrı): Dosya "descargar.py", satır 70, baskı e.reason içinde [0] [ 'kod'] TypeError: string endeksleri olmalıdır tamsayılar –
Maalesef bu @alecxe oldu bir süre önce, ne yaptığımı hatırlamıyorum, ama ben (istediğim gibi) kodu aldım. Yine de, cevabınız işe yarıyor, bu yüzden kabul ediyorum :) –