开发者

Python Equivalents of field.getInt(obj)

开发者 https://www.devze.com 2023-03-09 02:57 出处:网络
I\'m wondering how is the python equivalent of this code: Object owner; Object target String fieldname; Field field = owner.getClass().getField(fieldname);

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

精彩评论

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