邮递员正在向以python编写的函数发送请求。参数中有id。而且这种类型的id是uniqueidetifier(uuid4),但作为邮递员和json都是字符串。
类型uuid4出现“ AttributeError:'str'对象没有属性'id'”错误
python请求:
{
"items": [
{
"id": "18f72017-4a8b-4c82-bf0d-97b3fa01061b",
"total": 1000,
"comment": "test 1"
},
{
"id": "e54cf3a8-3fec-4321-bb43-8bcd106bf29d",
"total": 500,
"comment": "test 2"
}
]
}
def setpaymentapprove(work: directives.work, **items):
for item in items:
product = work.session.query(Product).filter(Product.id == item.id).first()
if product is not None:
product.total = item.total
product.comment = item.comment
work.session.add(product)
work.session.commit()
return BaseDto(True).toJson()
“ AttributeError:'str'对象没有属性'id'”
谢谢。