0

我希望能够使用变量从我的数据库中获取值,最后一行是我想要实现的。

class Data(db.Model):
  property = db.StringProperty()

data = Data(property = 'value')
data.put()

query = db.GqlQuery("SELECT * FROM Data")

myvar = 'property'

for line in query:
  line[myvar]
4

1 回答 1

1

谢谢你,

class Data(db.Model):
  property = db.StringProperty()

data = Data(property = 'value')
data.put()

query = db.GqlQuery("SELECT * FROM Data")

myvar = 'property'

for line in query:
  getattr(line, myvar)
于 2013-06-10T02:11:52.337 回答