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)
相关文章推荐
- python2.7web代码用python3.6运行时,浏览器发送请求报错TypeError: Object of type 'bytes' is not JSON serializable的解决办法
- Python3运行报错TypeError: Object of type bytes is not JSON serializable
- Python3 flask 解析post的json数据时报错,TypeError: Object of type 'bytes' is not JSON serializable
- 使用numpy库报错,TypeError: Object of type 'int64' is not JSON serializable.
- 在使用json.dumps时遇到报错TypeError: Object of type 'float32' is not JSON serializable
- TypeError: Object of type 'float32' is not JSON serializable
- Python json中的Object of type "xxx" is not JSON serializable通用解决办法
- TypeError:Object of type 'datetime' is not JSON serializable 和 json.dumps函数输出中文乱码解决方案
- TypeError: Object of type 'bytes' is not JSON serializable
- 【已解决】Object of type 'range' is not JSON serializable
- 【已解决】Object of type 'QuerySet' is not JSON serializable
- TypeError: object of type 'zip' has no len()、'zip' object is not subscriptable
- Python3 writerow函数TypeError: a bytes-like object is required, not 'str'
- Python中3+版本运行2+版本程序出现TypeError: a bytes-like object is required, not 'str'之读取PDF中的图片
- [scrapy] exceptions.TypeError:XXX is not json serializable
- datetimeTypeError: datetime.datetime(2015, 1, 29, 8, 17, 41) is not JSON serializable
- python错误1:TypeError: 'int' object is not iterable
- Uncaught TypeError: Property 'submit' of object # is not a func
- 【Python 笔记】命名域之 TypeError 'DataFrame' object is not callable
- python TypeError: 'builtin_function_or_method' object is not iterable keys