我收到这个错误:
KeyError: 'Ítem' Traceback (most recent call last) when I am writing the code `response['Ítem']` where response is equal to
{'Item': {'partner_id': '1002'}, 'ResponseMetadata': {'RequestId': 'IBKSRRDTFDLT6V7KI06PNGJA2FVV4KQNSO5AEMVJF66Q9ASUAAJG', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Server', 'date': 'Mon, 21 Feb 2022 14:52:36 GMT', 'content-type': 'application/x-amz-json-1.0', 'content-length': '36', 'connection': 'keep-alive', 'x-amzn-requestid': 'IBKSRRDTFDLT6V7KI06PNGJA2FVV4KQNSO5AEMVJF66Q9ASUAAJG', 'x-amz-crc32': '311453952'}, 'RetryAttempts': 0}}
所以为什么我在尝试访问"项目"时会出现错误。
整个功能代码为:
def getPartner(partner_id):
response = table.get_item(
Key={
'partner_id': partner_id
}
)
return buildResponse(200,response['Ítem'])
由于python是一种casesensitive
编程语言,因此Item
和Ítem
是而不是相同的值。