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

我想将字符串转换为实体的属性。可以如上。

4

1 回答 1

3

您正在寻找的是setattr

setattr(per, "ismarried", "yes")
于 2012-10-08T15:25:04.330 回答