Python 具有预期值的boto3 dynamodb更新项

Python 具有预期值的boto3 dynamodb更新项,python,amazon-dynamodb,boto3,Python,Amazon Dynamodb,Boto3,我只想在项目存在时更新它。如果我不使用预期值,则会插入不存在的项 dynamo.update_item(TableName=tableName, Expected={"myVar":{"Exists":True},{"Value":{"S":"myValue"}}}, Key={"myVar":"myValue"}, AttributeUpdates={"myVar":{"Action":"PUT", "Value":"myNewValue"}}) 这给了我一个错误。有什么帮助吗?这是我的答案

我只想在项目存在时更新它。如果我不使用预期值,则会插入不存在的项

dynamo.update_item(TableName=tableName, Expected={"myVar":{"Exists":True},{"Value":{"S":"myValue"}}}, Key={"myVar":"myValue"}, AttributeUpdates={"myVar":{"Action":"PUT", "Value":"myNewValue"}})
这给了我一个错误。有什么帮助吗?

这是我的答案:

dynamo.update_item(TableName=tableName, Expected={"myVar":{"Exists":True, "Value":myValue}}, Key={"myVar":myValue}, AttributeUpdates={"myVar":{"Action":"PUT", "Value":myNewValue}})
如果条件为非true,则引发异常:ConditionalCheckFailedException