if e.message[0]['code'] == 32: ##Account suspended : [{u'message': u'Could not authenticate you', u'code': 32}]': ##Account suspended : [{u'message': u'Could not authenticate you', u'code': 32}]
TypeError:字符串索引必须是整数,而不是str
我认为e是[{u'message': u'Could not authenticate you', u'code': 32}]
什么是问题?
答案 0 :(得分:1)
你明确地错误地访问它,因为消息和代码是彼此并排的,代码不属于消息。但是您的错误消息也与您认为e
的内容不一致。请尝试以下选项:e.code
,e["code"]
,e[0].code
,e[0]["code"]