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

我想将字符串转换为实体属性。是否可以如上所述。

最佳答案

您要查找的是setattr

setattr(per, "ismarried", "yes")

关于python - Google App Engine将字符串转换为(实体的)属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12784648/

10-10 16:13