class DecimalEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, decimal.Decimal): return float(o) super(DecimalEncoder, self).default(o)
调用:
json.dumps(res_dic, cls=DecimalEncoder)