class Foo(object): def __init__(self): self.name = '吴佩琪' self.age = 100 def baobao(self): print("哈哈") obj = Foo() setattr(obj, 'email', 'wupeiqi@xx.com') # 拿到对象中所有的属性信息 print(obj.__dict__) # 一句话拿到一个字典