기존 사전 키에 값을 추가하려고했습니다. 이 값은 db.Model Car
에서 제공되며 price
이라는 속성이 있습니다.사전에 존재하는 사전 키에 값을 추가하십시오.
두 개의 코드 블록을 시도했지만 AttributeError가 발생했습니다. 'GqlQuery'객체에는 'price'속성이 없습니다.
items = {"BE1234":"2","BE1923":"3","BE2032":"1", etc}
------------------------------------------------------------
block 1)
for item in items:
cars = db.GqlQuery('SELECT * FROM Car WHERE item=:1',item)
items[item] = cars.price
------------------------------------------------------------
block 2)
for item in items:
cars = db.GqlQuery('SELECT * FROM Car WHERE item=:1',item)
items.update({item:cars.price})
내가 얻을 찾고 있어요 것은 :
items = {"BE1234":["2","100"],"BE1923":["31","200"],"BE2032":["19","300"], etc}
업데이트 (최종 작업 코드)
for item in items:
cars = db.GqlQuery('SELECT * FROM Car WHERE item=:1',item)
for car in cars:
items[item]=[items[item],str(car.price)]
쿼리 없음을 반환하지되며, 테이블 차 필드 가격이 있는지 확인을 – shiva