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'}
原文地址:https://www.cnblogs.com/hanfe1/p/13330960.html