簡體   English   中英

嘗試使用 Python 3.7 更新 Dynamodb 時出現錯誤“無法更新:一元 +:'str' 的錯誤操作數類型”

[英]Error “could not update: bad operand type for unary +: 'str'” when trying to update Dynamodb using Python 3.7

我正在嘗試在 Python3.7 中運行以下更新:

 response = table.update_item(
            Key={
                "receipt_number": + receiptnumber,
                "update_date": + str(update_date)
            },
            UpdateExpression="set receipt_status=:new_receipt_status",
            ExpressionAttributeValues={
                ":new_receipt_status": +receiptstatus_val
            },
            ReturnValues="UPDATED_NEW"
        )

update_date 的值為“20210322”

運行此更新時出現錯誤“無法更新:一元 + 的錯誤操作數類型:'str'”

我試圖在沒有 str() function 的情況下通過它,但目前沒有解決方案。 感謝任何幫助。

它應該看起來像這樣。 在 dynamodb 中使用 update_item 時不需要 + 操作數

response = table.update_item(
            Key={
                "receipt_number": receiptnumber,
                "update_date": update_date
            },
            UpdateExpression="set receipt_status=:new_receipt_status",
            ExpressionAttributeValues={
                ":new_receipt_status": receiptstatus_val
            },
            ReturnValues="UPDATED_NEW"
        )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM