返回对象时字典化

class BaseResponse:

  def __init__(self):

    self.code = None

    self.error = None

    self.data = None

  @property

  def rdict(self):

    return self.__init__ 

ret = BaseResponse()

print(ret.rdict)

原文地址:https://www.cnblogs.com/ttyypjt/p/11023137.html