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)

相关文章:

  • 2021-11-21
  • 2022-02-13
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-01-01
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-11-30
  • 2021-12-28
  • 2021-06-29
  • 2021-09-27
相关资源
相似解决方案