I'm wondering how is the python equivalent of this code:
Object owner;
Object target
String fieldname;
Field field = owner.getClass().getField(fieldname);
int i = field.getInt(target);
开发者_开发问答
Thanks
i = getattr(target, fieldname)
See the documentation for getattr.
精彩评论