# keyid is a string used for id in ndb keys. quest.reward=['1commonhead']
for keyid in quest.reward:
item = ndb.Key('InventoryItem',keyid).get().toDict()
rewards.append(item)
TypeError: Key id 必须是字符串或数字;收到 {'gearType': '', 'level': 1L, 'color': 'lime', 'intelligence': 2L, 'damage': 2L, 'className': 'uncommonsword', 'grade': 'uncommon' , 'subType': 'sword', 'prettyName': '稀有松鼠之剑', 'type': 'weapon'}
我试过传递 kwds use_cache 和 use_memcache False 但这似乎不起作用。这是我目前的修复。我觉得很乱。我错过了有关上下文缓存的内容吗?
rewards = []
for keyid in quest.reward:
item = keyid
if type(keyid) == str:
item = ndb.Key('InventoryItem',keyid).get().toDict()
rewards.append(item)