我在Ubuntu 16.04 LTS中使用Python 2.7.12.我正在学习如何使用以下链接中的boto3:https://boto3.readthedocs.io/en/latest/guide/quickstart.html#using-boto-3 .我怀疑的是何时使用资源,客户端或会话以及它们各自的功能.
我在AWS Lambda上有一个简单的Python函数,该函数只是将一些数据放入DynamoDB表中,据我所知,我遵循的是Bot3文档中put_item()函数的正确格式。我收到以下似乎无法调试的错误:
"errorMessage":
"Parameter validation failed:\nInvalid type for parameter
Item.GSRResults.L[0], value: 3.8, type: <class 'float'>, valid types: <class 'dict'>
\nInvalid type for parameter Item.GSRResults.L[1], value: 3.4, type: <class 'float'>, valid types: <class 'dict'>\... snip...
\nInvalid type for parameter Item.GSRResults.L[9], value: 3.3, type: <class 'float'>, valid types: <class 'dict'>",
"errorType": "ParamValidationError",
"stackTrace": [
[
"/var/task/index.py",
39,
"upload_test",
"Item=item"
],
Run Code Online (Sandbox Code Playgroud)
这是Python函数:
def upload_test(event, context):
if event['httpMethod'] == 'POST':
info = event['body']
item = info['Item']
return respond(None, dynamo.put_item(
TableName="TestResults",
Item=item))
Run Code Online (Sandbox Code Playgroud)
这是我发送的JSON:
{
"body": …Run Code Online (Sandbox Code Playgroud)