马龙前越

导航

python-getattr

getattr(objectname[, default])

Return the value of the named attribute of object.  name must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.

posted on 2016-11-22 21:25  马龙前越  阅读(232)  评论(0编辑  收藏  举报