python boto3 dynamodb查询函数动态参数

python boto3 dynamodb查询函数动态参数,python,amazon-dynamodb,boto3,Python,Amazon Dynamodb,Boto3,Python boto3库dynamodb.query方法。 我们如何传递动态参数 client = boto3.resource("dynamodb") params = { "Limit": 10, "ExpressionAttributeNames":{"#pk":"pk"}, "ExpressionAttributeValues":{":pk":"value"}, "KeyConditionExpression":"#pk=:pk", "Scan

Python boto3库dynamodb.query方法。 我们如何传递动态参数

client = boto3.resource("dynamodb")

params = {
    "Limit": 10,
    "ExpressionAttributeNames":{"#pk":"pk"},
    "ExpressionAttributeValues":{":pk":"value"},
    "KeyConditionExpression":"#pk=:pk",
    "ScanIndexForward": False
}
res = client.query(params)
它的响应是错误的:

An error occurred (ValidationException) when calling the Query operation: Either the KeyConditions or KeyConditionExpression parameter must be specified in the request.

尝试使用**正确设置参数:

res = client.query(**params)