我尝试运行一个lambda函数,它接受关于AWS IoT Dash按钮的attribute
,它的serialNumber
,并在DynamoDB中查询它。因此,它应该打印整行。在
这是代码--->
from __future__ import print_function
import boto3
import json
import decimal
from boto3.dynamodb.conditions import Key, Attr
def lambda_handler(event, context):
print ('Init 1Push_Care_DATAprint')
print (event)
serialNumber = event['serialNumber']
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
if o % 1 > 0:
return float(o)
else:
return int(o)
return super(DecimalEncoder, self).default(o)
dynamodb = boto3.resource('dynamodb',region_name='us-east-1')
table = dynamodb.Table('1Push_Care_USERinfo')
response = table.query(
KeyConditionExpression=Key('Device_ID').eq('serialNumber')
)
items = response['Items']
print(items)
这是我一直收到的错误消息--->
^{pr2}$
错误出现的原因是愚蠢的。简单的解决方案是简单地消除一些标签。退格,这样一切都有适当的缩进。在
相关问题 更多 >
编程相关推荐