📌  相关文章
📜  TypeError:ndarray 类型的对象不是 JSON 可序列化的 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:15.231000             🧑  作者: Mango

代码示例1
import numpy as np
import codecs, json 

a = np.arange(10).reshape(2,5) # a 2 by 5 array
b = a.tolist() # nested lists with same data, indices
file_path = "/path.json" ## your path variable
json.dump(b, codecs.open(file_path, 'w', encoding='utf-8'), separators=(',', ':'), sort_keys=True, indent=4) ### this saves the array in .json format