python __dict__

class BaseResponse:
	def __init__(self):
		self.status = True
		self.error = 'error_msg'
		self.data = 'detail_data'

	@property
	def dict(self):
		return self.__dict__

obj=BaseResponse()
print(obj.dict) #{'status': True, 'error': 'error_msg', 'data': 'detail_data'}


print(obj.__dict__) # {'status': True, 'error': 'error_msg', 'data': 'detail_data'}
posted @ 2020-07-17 16:38  hanfe1  阅读(124)  评论(0编辑  收藏  举报