您的位置:首页 > 编程语言 > Python开发

python-TypeError: Object of type 'Decimal' is not JSON serializable 报错

2019-04-22 10:04 1451 查看
class DecimalEncoder(json.JSONEncoder):

def default(self, o):

if isinstance(o, decimal.Decimal):
return float(o)

super(DecimalEncoder, self).default(o)
j = json.dumps(xxxxxxx,cls=DecimalEncoder)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐