setattr(object, name, value)¶

This is the counterpart of getattr(). The arguments are an object, a string and an arbitrary value. The string may name an existing attribute or a new attribute. The function assigns the value to the attribute, provided the object allows it. For example, setattr(x, 'foobar', 123) is equivalent to x.foobar = 123.

posted @ 2017-06-22 20:10  2021年的顺遂平安君  阅读(227)  评论(0编辑  收藏  举报