开发者

Google Model Attribute get by name

Can I get a google model attribute by passing a string to some function?开发者_开发百科

To illustrate:

If I were to do .properties().keys(), it would return all the attributes as a list of strings.

If 'Person' is a model and 'age' is an attribute of person, I would like to do something like this:

Person.properties()['age'] = 25

where I set the person's age to 25


Use Python's setattr:

setattr(a_person, 'age', 25)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜