28 对象的封装并返回值
常用与ajax数据返回:
class BaseResponse(object):
def __init__(self, status=False, detail=None, data=None):
self.status = status
self.detail = detail
self.data = data
@property
def dict(self):
return self.__dict__
obj = BaseResponse(status=True)
print(obj.dict) # {'status': True, 'detail': None, 'data': None}