我正在使用tweepy制作Twitter应用程序。当用户发推文/更新个人资料等时,他们会遇到一些错误。我希望对这些错误进行分类,并向用户提供更多信息。
try:
tweet/update profile/ follow....
except tweepy.TweepError, e:
if tweepy.TweepError is "Account update failed: Description is too long (maximum is 160 characters)"
Do something
if tweepy.TweepError is "Failed to send request: Invalid request URL: http://api.twitter.com/1/account/update_profile.json?location=%E5%85%B5%E5%BA%A"
Do something
if tweepy.TweepError is "[{u'message': u'Over capacity', u'code': 130}]"
Do something
分类错误的唯一方法是将e
与字符串进行比较,例如:帐户更新失败:说明太长(最多为160个字符)
吗?