开发者

Python Equivalents of field.getInt(obj)

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜