你知道是否有一个内置函数来从任意对象构建一个字典?我想做这样的事情:
>>> class Foo: ... bar = 'hello' ... baz = 'world' ... >>> f = Foo() >>> props(f) { 'bar' : 'hello', 'baz' : 'world' }
注意:它不应包括方法.只有字段.
python attributes dictionary metaprogramming object
attributes ×1
dictionary ×1
metaprogramming ×1
object ×1
python ×1