📜  python 类按名称获取属性 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:53.145000             🧑  作者: Mango

代码示例1
>>> class c:
        pass
o = c()
>>> setattr(o, "foo", "bar")
>>> o.foo
'bar'
>>> getattr(o, "foo")
'bar'