TypeError: Object of type set is not JSON serializable
今天运行flask项目突然报TypeError: Object of type set is not JSON serializable错误,上网搜了一下
该对象是set形式,json序列不支持,回到代码查看,是之前改了数据形式但是一直没测试运行,找到哪里给html传输了set数据。
json不支持set格式,把集合转成列表,正常运行
session['qx'] = list(set(data[0][0].split(',')) if data else [' '])
TypeError: Object of type XXX is not JSON serializable ,看报错说明是什么类型不支持,找到该类型数据把他转为 json 支持的形式(字符串、列表、字典)就可以了。
TypeError: Object of type set is not JSON serializable相关推荐
- Flask API TypeError: Object of type 'Response' is not JSON serializable
Flask API TypeError: Object of type 'Response' is not JSON serializable 错误代码: session['image'] = str ...
- 成功解决TypeError: Object of type 'ndarray' is not JSON serializable
解决问题 TypeError: Object of type 'ndarray' is not JSON serializable 解决方法 def default(self, obj):if isi ...
- 【文件处理】——字典写入json文件或TXT文件,读取文件中的字典TypeError: Object of type ‘ndarray‘ is not JSON serializable错误解决方法
目录 一.将字典写入json文件 二.json文件中读取字典 三.将字典写入TXT文件中 四.从TXT中读取字典 五.解决字典含数组存入json文件失败的方法 1.存入前将数组变成列表 2.扩展类方法 ...
- labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable
最近在做MaskRCNN 在自己的数据(labelme)转为COCOjson格式遇到问题:TypeError: Object of type 'int64' is not JSON serializa ...
- TypeError: Object of type 'datetime' is not JSON serializable
json序列化时间对象的时候报错: TypeError: Object of type 'datetime' is not JSON serializable 解决办法 重写json序列化类 # -* ...
- 返回 JSON 格式数据报错:TypeError: Object of type set is not JSON serializable
在做 flask 项目的时候需要返回一个 JSON 数据,运行的过程中却报错:TypeError: Object of type set is not JSON serializable 报错位置如下 ...
- Python TypeError: Object of type ‘Decimal‘ is not JSON serializable 类型错误 无法json
场景:今天使用python 查询了一个MYSQL 数据库的信息 数据库的字段为decimal 类型 我将结果进行json.dumps 报错 TypeError: Object of type 'De ...
- 记录:TypeError: Object of type int32 is not JSON serializable。
rect_list = list()...rect_list.append(rect1)rect_list.append(rect2)...rsp = {'rect-list': rect_list} ...
- TypeError: Object of type ‘TrackedArray‘ is not JSON serializable
如果x是Object of type 'TrackedArray',那么这里使用x.tolist()可以解决问题,转化为list
最新文章
- XAMPP下的MYSQL解决中文乱码问题
- 白话Elasticsearch31-深入聚合数据分析之bucket与metric
- 一个关于c++string比较的问题
- SQL server注入
- memcached客户端_分布式算法真是吊炸天 – memcached - 第287篇
- Go之Channel
- c语言运行后出现xt073,2017年北京工业大学城市交通学院894C语言与数据结构之C程序设计考研强化模拟题...
- mfc listbox删除多行
- jQuery.extend函数详细用法![转]
- 算法——排序——快速排序图解动画
- 日撸 Java 三百行(71-80天,BP 神经网络)
- 用C语言多线程描述哲学家,并行程序设计-哲学家就餐问题
- mscorsvw.exe进程占用CPU资料80%以上的原因
- html未响应是什么原因,ie浏览器未响应如何解决
- 互联网大佬纷纷搞养殖,这是为哪般~~~
- 自己制作icon图标
- java调用百度翻译_Java调用百度API实现翻译-Go语言中文社区
- self training
- 360云盘丢失资料,官方承诺的永不删除丢失和绝对保密纯属忽悠
- 大学期间的副业赚钱之道