Object of type 'ndarray' is not JSON serializable

import numpy as np
import json arr=np.asarray([345,45])
result={'name':'test','num':ar} json.dump(result)

解决方法:

result={'name':'text','num':ar.tolist()}

json不认numpy的array

Object of type 'ndarray' is not JSON serializable的更多相关文章

  1. TypeError: Object of type 'int32' is not JSON serializable ——已解决

    将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...

  2. labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable

    最近在做MaskRCNN 在自己的数据(labelme)转为COCOjson格式遇到问题:TypeError: Object of type 'int64' is not JSON serializa ...

  3. TypeError: Object of type 'int32' is not JSON serializable

    将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...

  4. celery 4.1下报kombu.exceptions.EncodeError: Object of type 'bytes' is not JSON serializable 处理方式

    #python代码如下 from celery import Celeryimport subprocess app = Celery('tasks', broker='redis://localho ...

  5. Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化

    Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化 一般原因为 序列化的对象 ...

  6. TypeError: Object of type 'int64' is not JSON serializable

    错误类型:TypeError: Object of type 'int64' is not JSON serializable 错误场景:对Numpy和Pandas结果进行json.dumps报错 错 ...

  7. TypeError: Object of type 'ListSerializer' is not JSON serializable

    问题: 解决:ser.data是json数据,你想要的

  8. Object of type Decimal is not JSON serializable

    json遇到Decimal 型数据无法正确处理 解决方案 import json result = [ {'name': '小红', 'age': 26, 'balance': decimal.Dec ...

  9. typeerror object of type ‘decimal‘ is not json serializable jsonify

    当使用flask的jsonify返回json数据时,由于数据库有些字段类型使用decimal,而jsonify无法处理 解决方案 导入下面的包即可解决 pip install simplejson

随机推荐

  1. 重塑云上的 Java 语言

    音乐无国界,但是音乐人有国界. 云原生亦如此.虽没有限定的编程语言,但应用所使用的编程语言已经决定了应用部署运行的行为. Java 诞生于20年前,拥有大量优秀的企业级框架,践行 OOP 理念,更多体 ...

  2. luogu P1037 产生数 x

    P1037 产生数 题目描述 给出一个整数 n(n<10^30) 和 k 个变换规则(k<=15). 规则: 一位数可变换成另一个一位数: 规则的右部不能为零. 例如:n=234.有规则( ...

  3. [CSP-S模拟测试]:简单的期望(DP)

    题目描述 从前有个变量$x$,它的初始值已给出. 你会依次执行$n$次操作,每次操作有$p\%$的概率令$x=x\times 2$,$(100−p)\%$的概率令$x=x+1$. 假设最后得到的值为$ ...

  4. (转)SSL工作原理

    转:https://www.cnblogs.com/bhlsheji/p/4586597.html 挑    希望:SSL使用数据加密.身份验证和消息完整性验证机制,基于TCP和其他的应用层协议提供可 ...

  5. 修改mac默认python版本 为python3

    mac一般自带python2.7 可以修改 ~/.bash_profile (具体的path取决于你的python3安装路径): vi ~/.bash_profile # 添加这一行 alias py ...

  6. Java实体类之间的映射(一对一关系)

    如下描述:一个人有有一个身份证 一个身份证只能属于某一个人 /** 一个人有有一个身份证 一个身份证只能属于某一个人 */ class Person{ //人 private String name; ...

  7. page size

    https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_page_size https://dev.mysql.com/doc/refma ...

  8. fedora23禁用不需要的服务?--systemd服务单元?

    sign up: 签约; 登记, 注册. i'll sign up and go to the front and fight. he persuaded the company to sign up ...

  9. CBAM: Convolutional Block Attention Module

    1. 摘要 作者提出了一个简单但有效的注意力模块 CBAM,给定一个中间特征图,我们沿着空间和通道两个维度依次推断出注意力权重,然后与原特征图相乘来对特征进行自适应调整. 由于 CBAM 是一个轻量级 ...

  10. python twisted异步将数据导入到数据库中

    from twisted.enterprise import adbapi from twisted.internet import reactor def creat_conn(): # 数据库基本 ...