1、getattr

  1. class Mydict(dict):
  2. def __init__(self,value):
  3. self.value = value
  4. def __getattr__(self, item):
  5. return "can not find"
  6. if __name__ == '__main__':
  7. ret = Mydict(10)
  8. print(ret.value)
  9. print(ret.name)

2、setattr

3、delattr