dir(obj)
为您提供对象的所有属性。您需要自己从方法等中过滤出成员:
class Example(object): bool143 = True bool2 = True blah = False foo = True foobar2000 = Falseexample = Example()members = [attr for attr in dir(example) if not callable(getattr(example, attr)) and not attr.startswith("__")]print members会给你:
['blah', 'bool143', 'bool2', 'foo', 'foobar2000']



