擅长:python、mysql、java
<p>或者您可以向模型添加计算属性,如下所示:</p>
<pre><code>class Taxes(ndb.Model):
name = ndb.StringProperty()
id = ndb.ComputedProperty(lambda self: self.key.id())
</code></pre>
<p>然后在get方法中,只要调用dict,就可以得到id</p>
<pre><code>rows = [row.to_dict() for row in Taxes.query()]
self.response.write(json.dumps(rows))
</code></pre>