我在 lambda 函数中使用 boto3 将信息写入 dynamodb 表。
我收到错误put_item() only accepts keyword arguments。
在网上搜索,我发现这个错误可能意味着我没有匹配 dynamodb 分区键,但在我看来我做的一切都是正确的。
谁能帮我找出错误?对不起,这是我第一次使用 aws。
这是我的 lambda 函数
import json, boto3
def updateDynamo(Item):
dynamodb = boto3.resource('dynamodb', region_name = 'eu-central-1')
table = dynamodb.Table('userInformations')
response = table.put_item(Item)
return response
def lambda_handler(event, context):
userAttributes = event["request"]["userAttributes"]
email = userAttributes["email"]
name = userAttributes["name"]
Item = {
"email": email,
"name" : name
}
response = updateDynamo(Item)
print(email, name)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的测试事件:
{
"version": "string", …Run Code Online (Sandbox Code Playgroud) 使用type(z1[0])我得到jaxlib.xla_extension.ArrayImpl。打印z1[0]我明白了Array(0.71530414, dtype=float32)。我怎样才能得到实际的号码0.71530414?
我尝试过z1[0][0],因为z1[0]是一种具有单个值的数组,但它给了我一个错误:IndexError: Too many indices for array: 1 non-None/Ellipsis indices for dim 0.。
我还尝试了一种不同的方法:我在网上搜索是否可以从 jaxnumpy 数组转换为 python 列表,但我没有找到答案。
有人可以帮助我获取对象内部的值吗jaxlib.xla_extension.ArrayImpl?
我有一个关于fetch在 html 文件中使用的简单问题。
我在 AWS Api Gateway 中创建了一个 API,它有一个简单的 GET 方法:GET 方法返回一个 json。
现在,如果我直接访问或使用邮递员访问我的方法的链接,它可以正常工作,但是当我尝试使用fetch错误时,我看不到任何结果。
我在互联网上搜索,因为我既不知道 javascript 也不知道 html,但我找不到如何使它正常工作。例如,我在下面的代码中尝试做的是将通过 GET 获取的 json 放入标签中。
这是我的 html 文件:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>test.html</title>
</head>
<body>
<dl>
<dt>Page 1</dt>
<dd>Go to <a href="https://xxx.execute-api.eu-central-
1.amazonaws.com/prod/getcustomerdetailsbyemail/">link</a></dd>
</dl>
<p> <input name="Button" value="Click me" onclick="buttonClick()" type="button"> <input
name="Button2" value="Click me 2" formmethod="get" onclick="buttonClick2()" type="button">
</p>
<p> <input id="myText" name="Message" value="Insert text" type="text"></p>
<label for="myText" id="mylabel"></label>
<div id="myData"> </div>
<dl> …Run Code Online (Sandbox Code Playgroud)