Google App Engine 将字符串转换为(实体的)属性

问题描述 投票:0回答:1
class Personel(db.Model):
  ismarried=db.StringProperty()


class AddPersonal(webapp.RequestHandler):
  def get(self):
    per=Personal()
    #i want use a function at below, instead of per.ismarried
    per.whatisthisfunction("ismarried")="yes"
    per.put

我想将字符串转换为实体的属性。可以像上面那样吗

python google-app-engine
1个回答
3
投票

您要找的是

setattr
:

setattr(per, "ismarried", "yes")
© www.soinside.com 2019 - 2024. All rights reserved.