📜  python 遍历对象字段 - Python 代码示例

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

代码示例1
>>> dir(obj)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'bar', 'foo', 'func']

>>> [a for a in dir(obj) if not a.startswith('__')]
['bar', 'foo', 'func']