json存储格式问题 发表于 2020-03-31 | 分类于 python | 阅读次数: 12345678910111213问题:TypeError: Object of type 'int64' is not JSON serializable (或者float32)class NpEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.integer): return int(obj) elif isinstance(obj, np.floating): return float(obj) elif isinstance(obj, np.ndarray): return obj.tolist() else: return super(NpEncoder, self).default(obj)json.dumps(cxy_data, ensure_ascii=False,cls=NpEncoder)